Jump to content


Photo

PHP expanding navigation menu


  • Please log in to reply
9 replies to this topic

#1 angelac

angelac
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 05 October 2006 - 12:01 AM

Does anyone know where I can find an expanding navigation menu? 

#2 phporcaffeine

phporcaffeine
  • Members
  • PipPipPip
  • Advanced Member
  • 361 posts
  • LocationOhio, USA

Posted 05 October 2006 - 12:35 AM

This has nothing to do with php, google javascript or DHTML
Thanks,

Ryan Huff
President & Founder, MyCodeTree
support@mycodetree.com | http://mycodetree.com

#3 angelac

angelac
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 05 October 2006 - 12:43 AM

I'm looking for a PHP expanding navigation menu.  I want to use it in my pages using an include but I can't seem to find one that stays expanded on certain pages to let visitors choose from the submenus that apply to that page. 

Example: if someone visits the About Us page, I want the submenus to stay expanded so they can still choose from them without having to click About Us to expand the menu again.

Home
About Us
  Who we are
  Another Submenu
Contact Us
Visit Us

I don't want any JavaScript but CSS is good.  Any ideas?


#4 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 12:48 AM

Do you think you could write your own?  Make whatever page you are on have the expanded menu?

#5 angelac

angelac
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 05 October 2006 - 01:00 AM

I'm looking for a menu just like this:

http://www.indiana.e.../students/more/

The one on the left.  As you click on a link, the page changes and submenus are displayed.  A visitor can also tell what section they are in by looking at this menu.  I'd like something like that but I don't want to use Javascript, I know that they did in this one. 

I have one very similar to this here: http://mprirecdiv.com/php/submenu.php but I'm not sure how to keep it stuck once a user visits another page.  If I'm using an include, the menu always resets.

#6 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 01:09 AM

Just use if statements.

<?php
$page = 'home';

echo '<a href="home.php">Home</a>';
if($page == 'home')
{
echo '<a href="link1.php">Link 1</a>';
echo '<a href="link2.php">Link 2</a>';
echo '<a href="link3.php">Link 3</a>';
}

echo '<a href="about.php">About Us</a>';
if($page == 'about')
{
echo '<a href="link1.php">Link 1</a>';
echo '<a href="link2.php">Link 2</a>';
echo '<a href="link3.php">Link 3</a>';
}



#7 angelac

angelac
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 05 October 2006 - 01:14 AM

I'm not sure that would work in my code:

<?php
    $headers = array(               
            'COMPANY HEADQUARTERS' => 'submenu.php?s=1',               
            'BELLE HAVEN' => 'submenu.php?s=2',               
            'DOVER' => 'submenu.php?s=3',
            'EASTON' => 'submenu.php?s=4',
            'ELKTON' => 'submenu.php?s=5',
            'GEORGETOWN' => 'submenu.php?s=6',
            'NEWARK' => 'submenu.php?s=7',
            'SALISBURY' => 'submenu.php?s=8',
            'WILMINGTON' => 'submenu.php?s=9',
            );

    $sub_1 = array(
            'Recruiters' => 'http://usarmy-delmarva.com'
            'Future Soldiers' => 'http://usarmy-delmarva.com'
            'Schools' => 'http://usarmy-delmarva.com'
            'News/Events' => 'http://usarmy-delmarva.com'
            'Army Reserve Units' => 'http://usarmy-delmarva.com'
            );

    $sub_2 = array(         
            'Recruiters' => 'http://usarmy-delmarva.com'
            'Future Soldiers' => 'http://usarmy-delmarva.com'
            'Schools' => 'http://usarmy-delmarva.com'
            'News/Events' => 'http://usarmy-delmarva.com'
            'Army Reserve Units' => 'http://usarmy-delmarva.com'
            );

  $sub_3 = array(         
            'Recruiters' => 'http://usarmy-delmarva.com'
            'Future Soldiers' => 'http://usarmy-delmarva.com'
            'Schools' => 'http://usarmy-delmarva.com'
            'News/Events' => 'http://usarmy-delmarva.com'
            'Army Reserve Units' => 'http://usarmy-delmarva.com'
            );
    $sub_4 = array(         
            'Recruiters' => 'http://usarmy-delmarva.com'
            'Future Soldiers' => 'http://usarmy-delmarva.com'
            'Schools' => 'http://usarmy-delmarva.com'
            'News/Events' => 'http://usarmy-delmarva.com'
            'Army Reserve Units' => 'http://usarmy-delmarva.com'
            );
    $sub_5 = array(         
            'Recruiters' => 'http://usarmy-delmarva.com'
            'Future Soldiers' => 'http://usarmy-delmarva.com'
            'Schools' => 'http://usarmy-delmarva.com'
            'News/Events' => 'http://usarmy-delmarva.com'
            'Army Reserve Units' => 'http://usarmy-delmarva.com'
            );
    $sub_6 = array(         
            'Recruiters' => 'http://usarmy-delmarva.com'
            'Future Soldiers' => 'http://usarmy-delmarva.com'
            'Schools' => 'http://usarmy-delmarva.com'
            'News/Events' => 'http://usarmy-delmarva.com'
            'Army Reserve Units' => 'http://usarmy-delmarva.com'
            );
    $sub_7 = array(         
            'Recruiters' => 'http://usarmy-delmarva.com'
            'Future Soldiers' => 'http://usarmy-delmarva.com'
            'Schools' => 'http://usarmy-delmarva.com'
            'News/Events' => 'http://usarmy-delmarva.com'
            'Army Reserve Units' => 'http://usarmy-delmarva.com'
            );
    $sub_8 = array(         
            'Recruiters' => 'http://usarmy-delmarva.com'
            'Future Soldiers' => 'http://usarmy-delmarva.com'
            'Schools' => 'http://usarmy-delmarva.com'
            'News/Events' => 'http://usarmy-delmarva.com'
            'Army Reserve Units' => 'http://usarmy-delmarva.com'
            );
    $sub_9 = array(         
            'Recruiters' => 'http://usarmy-delmarva.com'
            'Future Soldiers' => 'http://usarmy-delmarva.com'
            'Schools' => 'http://usarmy-delmarva.com'
            'News/Events' => 'http://usarmy-delmarva.com'
            'Army Reserve Units' => 'http://usarmy-delmarva.com'
            );     
 

foreach ( $headers as $key => $value ) {
        echo "<tr class='mainmenu'><td><a href='$value'>$key[/url]</td></tr>";
        if (($key == "COMPANY HEADQUARTERS") && ($s == "1")) {
                foreach ( $sub_1 as $key => $value ) {
                        echo "<tr class='submenu'><td><a href='$value'>$key[/url]</td></tr>";
                }

        }
        if (($key == "BELLE HAVEN") && ($s == "2")) {
                foreach ( $sub_2 as $key => $value ) {
                        echo "<tr class='submenu'><td><a href='$value'>$key[/url]</td></tr>";}
        }


        if (($key == "DOVER") && ($s == "3")) {
                foreach ( $sub_3 as $key => $value ) {
                        echo "<tr class='submenu'><td><a href='$value'>$key[/url]</td></tr>";}
        }

      if (($key == "EASTON") && ($s == "4")) {
                foreach ( $sub_4 as $key => $value ) {
                        echo "<tr class='submenu'><td><a href='$value'>$key[/url]</td></tr>"; }
        }
 
      if (($key == "ELKTON") && ($s == "5")) {
                foreach ( $sub_5 as $key => $value ) {
                        echo "<tr class='submenu'><td><a href='$value'>$key[/url]</td></tr>"; }
        }


      if (($key == "GEORGETOWN") && ($s == "6")) {
                foreach ( $sub_6 as $key => $value ) {
                        echo "<tr class='submenu'><td><a href='$value'>$key[/url]</td></tr>"; }
        }
     
        if (($key == "NEWARK") && ($s == "7")) {
                foreach ( $sub_6 as $key => $value ) {
                        echo "<tr class='submenu'><td><a href='$value'>$key[/url]</td></tr>";}
        }
     
        if (($key == "SALISBURY") && ($s == "8")) {
                foreach ( $sub_6 as $key => $value ) {
                        echo "<tr class='submenu'><td><a href='$value'>$key[/url]</td></tr>";}
        }
     
        if (($key == "WILMINGTON") && ($s == "9")) {
                foreach ( $sub_6 as $key => $value ) {
                        echo "<tr class='submenu'><td><a href='$value'>$key[/url]</td></tr>";}
        }
     
  }     
?>

#8 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 01:21 AM

Your code looks fine, but you use $key => $value twice. 

Try $inside_key => $inside_value

You are reasigning the $key and $value which is why it is not working.

#9 angelac

angelac
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 05 October 2006 - 06:06 PM

There is nothing in my code that tells it to stay expanded if it's on a certain section. 

When I use the $key => $value, that is simply to populate my links with my arrays.

No one knows of a php expanding menu?

#10 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 06 October 2006 - 10:26 PM

Most people use some sorta javascript to make expanding menus without having to refresh the page.  Well its all javascript/css etc (DHTML).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users