Welcome to WebmasterWorld Guest from 54.166.152.121

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Nested Menus - How To?

How to generate a nested template using PHP?

     
1:33 pm on Mar 25, 2007 (gmt 0)

10+ Year Member



In each of my .php web pages I include("menu.php") which contains a menu of links to my web site pages.

How can I modify this simple model (without using a database) in order to create a nested template?

Do I have to create a different menu.php file for each group of second level pages? Or can I accomplish a two level menu with a single menu.php file (and still without using a database)?

4:31 pm on Mar 26, 2007 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Could you clarify what you mean by the nested template? Is the menu not the same for all pages?
1:32 pm on Mar 29, 2007 (gmt 0)

10+ Year Member



By nested I mean that the menu expands into several submenus.
3:41 pm on Mar 29, 2007 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You could do this a number of ways. My personal preference would be to keep it all in one file and use logic to display the expanded portions if necessary. Another option is to use pop-out submenus as opposed to expanded menus.
4:54 pm on Mar 29, 2007 (gmt 0)

10+ Year Member



$_SERVER['PHP_SELF'] maybe the predefined variable that your looking for - it will give the filename (relative to the document root) of the page that the menu has been included on, you can then use that to determine which sub-menu(s) to display.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month