PHP Scripts Development » Discuss our Web Development Tutorials

Dynamic (2 level) navigation list

(4 posts)

Great offers not only for geeks!


  1. User has not uploaded an avatar

    metapeter
    Member

    First of all i'd like to thank Olaf for this wonderfull code, it's just great.

    (Sorry for my bad english in advance)

    Nevertheless the script is great, there is one thing i'd like to ask:

    I'd like to use this script for the navigation of a website with dynamic content. There is one templatefile ("index.php") beeing used and content was loaded this way until i found you script: "index.php?area=1".

    Now i thought i could load my contents with "index.php?menu=*" instead of "area", beacaue "menu=*" ist generated by the Script.

    Now my list looks like this:

    -Top1
    -Sub
    -Sub
    -Top2
    -Sub
    -Sub

    The Problem in an example: Top1 delivers "index?menu=1", but the subs of Top1 inherit the "index?menu=1". I cannot change content this way.

    Do you know a way how to get different "menu"-values in the subnavigation, or to get the navigation work for my purpose?

    Thank you a lot.

    Posted 3 months ago #
  2. User has not uploaded an avatar

    metapeter
    Member

    I tried to use "?area=1_1" as link_url in the DB for the first subnavigation point. It basically works fine for the subnavigation. The resulting links look like this: index.php?menu=1&area=1_1

    This would be fine if it would also work with the main navigation, but it only works for the subs.

    I can't figure out why the top navigation is handling the link_url differently. If i use "?area=1_0" as link_url for the fist main navigation point, it results in: index.php?area=1_0?menu=1

    As a matter of course this resulting link-url won't work.

    Do you know how to fix this?

    Posted 3 months ago #
  3. User has not uploaded an avatar

    metapeter
    Member

    Ok, forget everything i wrote ab`ove. But it do have one very appropiate question:

    Is there a way to get the current menu item (top and sub) marked with a css-class and does anybody know how to achieve this?

    I really would appreciate any help regarding above question.

    Regards, Peter

    BTW, the code - as it is now - results in a list with an empty pair of ul-tags after the non-active main menu items. This is a Problem for clean css-formating. I fixed it by replacing the emtpy ul-pair. To whom it may concern, I added this to your code after line 32:

    $repl_wert = '';
    $menu = ereg_replace("<ul id=\"subnav\">\n</ul>", $repl_wert, $menu);
    Posted 3 months ago #
  4. Sorry Peter, I forgot to answer this post ;)

    You need to compare some value to get the current state, I like this way to handle this:
    http://www.alistapart.com/articles/slidingdoors2/

    I you understand this system it would be easy to change the php code.

    ... thanks for sharing the code fix.

    Posted 3 months ago #

RSS feed for this topic

Reply

You must log in to post.