php - Opening submenu depending on the selected page -
i designing vertical drop menu (with submenus), here's how looks:
on left, no menu item selected. on middle , on right there sub-menus opened (and selected page in blue). 1 sub-menu can opened @ once (one opens => other closes). contents of menu not dynamic.
the big problem when opened new page, sub-menu of selected page had opened.
so decided pages links index.php?p=my_selected_page , in file menu.php built array:
$menu = array( 'présentation' => array( 'accueil' => 'accueil', 'inscription' => 'inscrivez-vous' ), 'nos actions' => array( 'mediation-familiale' => 'médiation familiale', 'droit-de-visite' => 'droit de visite accompagnée', 'accompagnement-familial' => 'accompagnement familial' ) // [...] ); then page $_get ['p']. through array , writes menu html match. if $_get['p'] 1 of key sub-array, display sub-menu css class menu open. (and link selected default).
while solution works, system allows me store links index.php?p=my_selected_page.
i wish put other links, forum.php (and include menu.php in forum.php), etc..
if have ideas make possible, grateful.
(i french. sorry spelling mistakes.)
you use $_server["script_name"] ask name of script file, , verification information, not sending variable via get. :)
e.g.
<?php $script_file = $_server["script_name"]; $no_slashes = explode('/', $script_file); $script_file = $no_slashes[count($no_slashes) - 1]; echo $script_file; ?> at point, have filename stored in $script_file, , match array's keys.
hope helps.
Comments
Post a Comment