SitePoint Sponsor

User Tag List

Results 1 to 22 of 22
  1. #1
    SitePoint Addict Ghz's Avatar
    Join Date
    Jun 2002
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to: navegation bar

    Hello there,
    I successfully could generate a function which allow me to add as much categories and subcategories as I want. Now, I need to generate another function which could build a linked navegation bar as my sites visitores go down surfing my categories and subcategories. It's much more like the navegation bar here in this forums.

    Any ideas?

    Any help would be highly appreciated in advance,
    Regards,
    Ghz

  2. #2
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    ble
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You mean like "SitePoint Forums > Program Your Site > PHP"
    And there are dotted lines are you progress?
    If someone was helpful, give them some 'rep'.

  3. #3
    SitePoint Addict Ghz's Avatar
    Join Date
    Jun 2002
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes exactly, That's what I meant

    Any clues?

  4. #4
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am also looking that.Have you got it?

  5. #5
    SitePoint Addict Ghz's Avatar
    Join Date
    Jun 2002
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not yet really. I could make a navegation bar but without being linked and as soon as I add any piece of html like links or anything else to it, it gives me an error. I'm still working on it and I wish anyone can help us never hisitate to do so.

    Regards,
    Ghz

  6. #6
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually,I know that it can be built on java script.but looking for any php script.
    I think it is good topics to do that

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Ghz
    not yet really. I could make a navegation bar but without being linked and as soon as I add any piece of html like links or anything else to it, it gives me an error. I'm still working on it and I wish anyone can help us never hisitate to do so.

    Regards,
    Ghz
    Post you nav code!
    That way we can maybe help you!!!!!

    Spike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #8
    SitePoint Addict Ghz's Avatar
    Join Date
    Jun 2002
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Here is a code for you

    I have made this small function so you can use it to generate a navigation bar. Feel free to use it. Now here is the code:

    PHP Code:
        function  nav_bar($id)
      {
       global 
    $ecats;
       
        
    $query mysql_query("SELECT * FROM your_table WHERE id='$id'");
        
    $row mysql_fetch_array($query);

        
    $cats "<a href=index.php>{$row['title']}</a>&nbsp;";
       
       if(
    $row['catid'] != 0) {
         
    nav_bar($row['catid']);
       }
         
    $ecats.= $cats;
         return 
    $ecats;
      }  
        
    $ecats "";
        
       
    nav_bar($id); 
    Thanks for everyone helped us in here. And I'm ready to help anyone who will need any kind of help.

    Regards,
    Hakeem

  9. #9
    \m/\m/ karinne's Avatar
    Join Date
    Dec 2002
    Location
    Aylmer, QC, Canada
    Posts
    409
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try changing
    PHP Code:
    $cats "<a href=index.php>{$row['title']}</a>&nbsp;"
    to
    PHP Code:
    $cats "<a href=index.php>".$row['title']."</a>&nbsp;"

  10. #10
    SitePoint Addict Ghz's Avatar
    Join Date
    Jun 2002
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why?

  11. #11
    \m/\m/ karinne's Avatar
    Join Date
    Dec 2002
    Location
    Aylmer, QC, Canada
    Posts
    409
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    doesn't {row['title']} show up when the page is displayed instead of the actual title?

  12. #12
    SitePoint Wizard realestate's Avatar
    Join Date
    May 2004
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Most relevant link should be on top or left, less relevant ones ones should be on right are at the bottom.
    ( s e o)

  13. #13
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just for reference, what you guys are talking about is commonly refered to as "breadcrumbs".
    Try searching on that and see if you find something.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  14. #14
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Although you haven't explicitly sais so, I assume that the data you store in your navigation table is hierarchical data, i.e. each row has a parent row. If this is the case, the doing breadcrimbs is relatively straight forward. Checkout this article http://www.sitepoint.com/article/hie...-data-database and use the modified preorder tree traversal method. All the code you need is in the article.

  15. #15
    Non-Member Musicbox's Avatar
    Join Date
    Nov 2004
    Location
    india
    Posts
    1,331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can simply create a mod in php which can show sub categories.

  16. #16
    SitePoint Addict Ghz's Avatar
    Join Date
    Jun 2002
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually I would like to thank you guys and girls for your participation in here. Secondly:
    doesn't {row['title']} show up when the page is displayed instead of the actual title?
    Yes, so what's the difference between yours and mine. I mean what's the point of using yours?


    you can simply create a mod in php which can show sub categories
    Is there someway to write a mod which can be easier than these few lines? I mean the idea is too simple and it will be greater if you could simplify it to us. Anyway, I have put this piece of code so that poeple can use and modify. If you are interested you can just go a head with it.

    Regards,
    Hakeem

  17. #17
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    Hailsham, UK
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually I would like to thank you guys and girls for your participation in here. Secondly:

    doesn't {row['title']} show up when the page is displayed instead of the actual title?
    Yes, so what's the difference between yours and mine. I mean what's the point of using yours?
    {$row['title']} does not show up as {$row['title']}, but the actual title will when used in double-quotes. So either's good.

    Rgds, Ian

  18. #18
    I &lt;3 Internet Tekime's Avatar
    Join Date
    Dec 2003
    Location
    Maine
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found it extremely useful to create a tree class to represent these types of data structures. It accepts active id, primary field, parent field, title, id field, etc. and optionally table name and some other configuration values.

    You can either create entries on the fly ($tree->add_entry) or build them automatically from a database ($tree->build()), or a combination of both. By using dynamic table and field names, you can build a tree from the table of your choice, then add and remove entries, and render it when you're done.

    I plugged in a custom menu rendering method (which took AGES!), so now I can build a tree, and spit it out as either breadcrumbs OR a very robust CSS menu with infinite levels of entries, active nodes, automatic collapsing, etc. I also created a method for myGoSuMenu output, which spits out a dynamic tree-like javascript menu.

    I would post some code but it's tightly coupled with my existing architecture and would be pretty useless to you. Anyway it was a great exercise in programming, I just thought I would throw some ideas out that have benefited me in my development greatly. The concepts behind a heirarchial structure like this show up all over the place in development, so this concept can really be extended to apply in a lot of places.
    Scriptalicious SEO Scripts
    Save 20% with coupon code SPROCKS


  19. #19
    SitePoint Evangelist CapitalWebHost's Avatar
    Join Date
    Apr 2003
    Location
    Albany, NY
    Posts
    417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First of all, that type of nav bar is called a "breadcrumb".

    Do a search of phpclasses.org for the term breadcrumb and you should find some classes that will assist in making them for you.

    Here's a breadcrumb class..

    http://www.baskettcase.com/classes/breadcrumb/

  20. #20
    SitePoint Evangelist CapitalWebHost's Avatar
    Join Date
    Apr 2003
    Location
    Albany, NY
    Posts
    417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As for Tekime...I use this class..

    http://www.phpclasses.org/browse/package/1268.html

    Works just like the one you described...I've made some modifications to it for customized use though.

  21. #21
    SitePoint Member
    Join Date
    Sep 2004
    Location
    India
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can anybody help me with a collapsible menu (vertical)??

  22. #22
    SitePoint Member sethnick99's Avatar
    Join Date
    Jan 2005
    Location
    New York
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just use DHTML and ASP. I find it is much easier and cleaner to.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •