Re: failure notice

From: Date: Sat, 17 Jun 2000 10:13:42 +0000
Subject: Re: failure notice
Groups: php.general 
Request: Send a blank email to php-general+get-2125@lists.php.net to get a copy of this message
** Reply to note from sarahana <sarahana@cyberjunkie.com> Sat, 17 Jun 2000 = 01:57:52 -0700 > > Hi, I have two select menus, the first has main categories and the > second one is empty initially. I want the second one to show the sub > categories of the selected main category once the user chooses the > main category... and of course, I want to do this without using > javascript.:-) Please help... You can do this by making the menu choices links. There are many ways to do it. The hard way, you build the menu for each page based on where in the main categories the page you are on is at. If you change your menu structure, you get to change it in every page that uses that menu. Not a good idea. In the examples that follow you would have to change the menu in up to 9 places. One easier way would be to place each of the main categories into its own directory, and create a menu file for each. Each page within the system could include the menu for that category. This is better as there are only three files with the menu in it. Example directory structure... /menu.plib /indes.php /category1/ /category1/menu.plib /category1/program11.php /category1/program12.php /category1/program13.php /category2/ /category2/menu.plib /category2/program21.php /category2/program22.php /category2/program23.php /category3/ /category3/menu.plib /category3/program31.php /category3/program32.php /category3/program33.ph What to put in the menu.plib files to get your expanding menus: /menu.plib category1 category2 category3 /category1/menu.plib category1 program11 program12 program13 category2 category3 /category2/menu.plib category1 category2 program21 program22 program23 category3 /category3/menu.plib category1 category2 category3 program31 program32 program33 All of that can be done with static files, and the right include()/require() statement where you want the menu to appear. require( 'menu.plib' ); or require( './menu.plib' ); You could even do it with SSI, and not use php at all. All the menu entries can be nothing more than normal links. &nbsp;&nbsp;&nbsp; <A Href=3D"/category1/program12.php">Program12</A><BR> But since you are using php you can do better, and have only one menu for the entire system. Again, all the programs in the system include the same menu. I am using $REQUEST_URI to obtain the full name and path of the program, from the web browsers point of view. You may have to use phpinfo() to find a sutable variable. <Warning: From memory, not tested> FILE: /menu.plib (There are no other menus) ------------------------------------------- <? <A Href=3D"/category1/help.html">Category1</A><BR> if( ereg( 'category1', $REQUEST_URI ) { &nbsp;&nbsp;&nbsp;<A Href=3D"/category1/program11.php'> Program11</A><BR> &nbsp;&nbsp;&nbsp;<A Href=3D"/category1/program12.php'> Program12</A><BR> &nbsp;&nbsp;&nbsp;<A Href=3D"/category1/program13.php'> Program13</A><BR> } <A Href=3D"/category2/help.html">Category2</A><BR> if( ereg( 'category2', $REQUEST_URI ) { &nbsp;&nbsp;&nbsp;<A Href=3D"/category2/program21.php'> Program21</A><BR> &nbsp;&nbsp;&nbsp;<A Href=3D"/category2/program22.php'> Program22</A><BR> &nbsp;&nbsp;&nbsp;<A Href=3D"/category2/program23.php'> Program23</A><BR> } <A Href=3D"/category3/help.html">Category3</A><BR> if( ereg( 'category3', $REQUEST_URI ) { &nbsp;&nbsp;&nbsp;<A Href=3D"/category3/program31.php'> Program31</A><BR> &nbsp;&nbsp;&nbsp;<A Href=3D"/category3/program32.php'> Program32</A><BR> &nbsp;&nbsp;&nbsp;<A Href=3D"/category3/program33.php'> Program33</A><BR> } ?> ------------------------------------------- Now you can change your menu from one place and have it properly adapt itself for the program that require()s it. This is a simplistic example, but hopefully it is understandable. You should be able to expand it as needed. This may look messy, and require a web transaction for each menu item that is clicked, but I don't think you should depend on javascript for the operation of your programs. There are stull too many browsers that don't support it, and people who insist on turning it off. Rick Widmer Internet Marketing Specialists www.developersdesk.com Rick Widmer Internet Marketing Specialists www.developersdesk.com

« previous php.general (#2125) next »