| 
	
 | 
 Posted by rigga on 09/17/05 22:18 
rigga wrote: 
 
> Hi, 
>  
> I am relatively new to php and am currently working on a site where I need 
> to use a collapsing menu system.  I have written the code to do this 
> however I am completely at a loss to do one particular thing.  To best 
> explain what the problem is I will give you an overview of how the menu 
> hangs together. 
>  
> The menu looks like this: 
>  
> Catagory1 (note these look like buttons) 
> Catagory2 
> Catagory3 
>  
> When a user clicks on a catagory that catagory expands to show the sub 
> catagories and the menu then looks like this ( assuming they clicked on 
> catagory1) 
>  
> Catagory1 
> subitem1 
> subitem2 
> Catagory2 
> Catagory3 
>  
> If you were to click on catagory2 then the sub items for that catagory 
> would appear and the sub items for catagory 1 would disappear. 
>  
> The menu script I created draws the catagories to look like buttons and 
> gives them a url in the form of 'index.php?s=#' so for example catagory1 
> has the url of 'index.php?s=1' 
>  
> The script draws the first 'button' (catagory1)and proceeds to check to 
> see if that catagory is active and if so it then populates the subitems 
> and then loops and draws the next button (catagory2). What I would like to 
> do is some how when a user click on catagory1 to have the script recognise 
> this and rather than give the button the url of 'index.php?s=1' when the 
> page is drawn to simply change it to a text lable, if the user was then to 
> click on button 2 (catagory2) it then needs to change button 2 url to just 
> a text lable and button 1 url back to 'index.php?s=1'. 
>  
> I hope this makes sense, i have included a cut down version of my menu 
> script which hopefully will make things clearer. 
>  
> Any help on this will be appreciated. 
> 
--------------------------------------------------------------------------------------------- 
> <?php 
> session_start(); 
> if ((isset($_SESSION['group'])) && (!isset($_GET['s']))) { 
>  $s = $_SESSION['group']; 
> } 
> else { 
>  $s = $_GET[s]; 
> } 
>  
> //Get current page 
> $page = $_SERVER['REQUEST_URI']; 
> // array holds menu button names and passes menu group value 
> $headers = array('Cars' => 'index.php?s=1','Bikes' => 'index.php?s=2'); 
>  
> $sub_1 = array( 
> 'Sports' => 'sports.php', 
> 'Family' => 'family.php', 
> '4x4' => 'fourby.php' 
> ); 
>  
> $sub_2 = array( 
> 'Motocross' => 'moto.php', 
> 'Road' => 'road.php', 
> 'Scooters' => 'scooter.php', 
> ); 
>  
> // Draw the menu 
> foreach ( $headers as $key => $value ) { 
>   
>  // Line below draws a button this is the part i want to be able to change 
>     the value of if that submenu is currently active 
>  echo "<div id=\"button\"><a href='$value'>$key</a></div>"; 
>   
>  $_SESSION['group'] = $s; 
>  if (($key == "Cars") && ($s == "1")) { 
>   foreach ( $sub_1 as $key => $value ) { 
>    $_SESSION['group'] = $s; 
>    // Check to see if page is active is so bold it 
>    if ($value == $page) { 
>     echo "<b><a href='$value'>$key</a></b>"; 
>    } 
>    else { 
>     echo "<a href='$value'>$key</a>"; 
>    } 
>   } 
>  
>  } 
>  
>  if (($key == "Bikes") && ($s == "2")) { 
>   $_SESSION['group'] = $s; 
>   foreach ( $sub_2 as $key => $value ) { 
>    $_SESSION['group'] = $s; 
>    // Check to see if page is active is so bold it 
>    if ($value == $page) { 
>     echo "<b><a href='$value'>$key</a></b>"; 
>    } 
>    else { 
>     echo "<a href='$value'>$key</a>"; 
>    } 
>   } 
>  } 
> } 
> ?> 
> 
-------------------------------------------------------------------------------------------- 
>  
> Please note I call this script as an include from my template 
>  
> Many thanks 
Nobody can help? or have I not explained this well enough?
 
  
Navigation:
[Reply to this message] 
 |