Jump to content


Photo

PHP tree navigation question


  • Please log in to reply
5 replies to this topic

#1 angelac

angelac
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 13 September 2006 - 04:04 PM

Hello all!  Newbie here...

I have a PHP tree navigation created for the redesign of my site.  Here's a look at it (the links are not correct): http://www.mprirecdi...php/submenu.php

It does exactly what I want it to do with one exception.  When I click on a station, ex. Dover, I want a certain webpage to be displayed along with the drop down menu options.  To be more specific, when you click on Dover I want it to take you to a page that has a picture of the station and an address.  The drop down menu will also be present so you will be able to view Dover Recruiters, Dover Soldiers, etc.

Does that make sense?

Here is 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</a></td></tr>";
        if (($key == "COMPANY HEADQUARTERS") && ($s == "1")) {
                foreach ( $sub_1 as $key => $value ) {
                        echo "<tr class='submenu'><td><a href='$value'>$key</a></td></tr>";
                }

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


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

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

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


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


#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 13 September 2006 - 04:26 PM

Why not just put this in a seperate file and just have a spot on those pages where you include it?

Info: PHP Manual


#3 angelac

angelac
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 13 September 2006 - 04:52 PM

I intend to use a snippet of code on all pages:
<?
include('nameofpage.php');
?>

so that I only have to change one navigation page. 

But...if I do that, then there is still no real link to each station, only a link to the values of the drop down menus. 

I just need to link the words of the stations to web pages.

#4 angelac

angelac
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 13 September 2006 - 05:24 PM

Here is an example of what I want to do:

http://www.zend.com/zend/tut/index.php

The navigation on the left is exactly what I want.  When a user clicks on a main topic, a new page shows up and the menu expands to show what other sections of that main topic are available.

Can anyone help? 

#5 cal_biker

cal_biker
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 14 September 2006 - 05:09 PM

i have a tree menu on my site if you like it i will send you the code.I think thats what you want.
www.calspl.com
drop me a line in www.calspl.com "contact me" form


#6 angelac

angelac
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 26 September 2006 - 03:16 PM

I sent a message in the contact form of your site some time ago, did you receive it?  I haven't heard anything back.

Thanks,
Angela




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users