Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorlatinomigs
    • CommentTimeMar 15th 2007
     permalink
    This post is a follow up to the discussion "Help with MySQL solutions for site navigation" that I started a few weeks ago. The problem was, how do I organize a multilevel site navigation hierarchy into a database? And from there, how do I output a nested unordered list? From suggestions here and other forums, and a helpful article at sitepoint I came up with the following solution.

    In this approach I'm dealing with two concepts: Recursion, and the Modified Preorder Tree Traversal method, which I learned all about from an article at sitepoint. The article can explain both concepts a lot better than I can so I wont try.

    I created a database for the example with the colums: id, label, level, lft, rgt

    The data for the example is a 4 level site nav loosely based on a project I'm working on.

    This is my first attempt at tackling this problem and if anybody has suggestions and I like to hear your ideas!

    Thanks.
    • CommentAuthorMatt
    • CommentTimeMar 15th 2007
     permalink
    Well, logically you will need to have probably 2 functions, one of the initial getting the list, and then one to execute if the category has a subcategory, and then that function will execute itself if the same condition occurs in that category. Ridged recursion is the worst, and I had to deal with it a while ago, but you will figure it out.
    • CommentAuthorlatinomigs
    • CommentTimeMar 15th 2007
     permalink
    lol, actually I did, that's what this post is about. Follow the solution link and you'll see that your suggestion is exactly what I did. I'm hoping that it'll be helpful to others who are new to the whole php/mysql driven website concept. And I'm interested to see if anybody can spot ways to make my approach more efficient or if there is a simpler alternative.
Add your comments
    Username Password
  • Format comments as (Help)