Solved

PHP Dynamic Navigation

Posted on 2010-09-01
9
400 Views
Last Modified: 2012-06-27
Hi Experts. I am trying to create a 2 or 3 tiered php navigation system. I do not want to use 3rd party software and need the simplest method possible as I am still a beginner. I have managed to create one level or tier and am assuming I would simply need to add another variable to achieve my objective however nothing seems to be working. I have attached the code below. If anyone has any suggestions please let me know. Thanks!
<table width="70%">

<tr>



<td width="20%">

<b>2010 Permits & Invoices</b><br/>

<a href="index.php?page=year">year</a><br/>



<?php



	$page = $_GET['page'];

    	if ($page)

    {

    	include("inc/".$page.".php");

    }



?>



</td>



</tr>

</table>

Open in new window

0
Comment
Question by:brettsky07
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 33582189
First question is what do you mean by "2 or 3 tiered php navigation system"?  Can you show us what you want it to look like and/or do?  Where is"$_GET['page']" coming from?
0
 
LVL 5

Expert Comment

by:drakeshe
ID: 33582330
what is inside page.php?
0
 
LVL 20

Expert Comment

by:virmaior
ID: 33582592
yeah, without knowing what is in page.php, there's really not much we can suggest...
if you really are going to have thousands of separate files, then your code would look something like the below.  

basically, you will want to use a delimiter to split the different segments. pick something that will never be one of the parameters.


usually you want to do pagination by using functions or objects so that you can have a single instance of code handle all the different pages for display and a second instance of code handle setting the parameter list.
<table width="70%">
<tr>

<td width="20%">
<b>2010 Permits & Invoices</b><br/>
<a href="index.php?page=year">year</a><br/>

<?php

        if (isset($_GET['param1']) and isset($_GET['param2'])) 
    {
	$page = $_GET['param1'] . '_' . $_GET['param2'];
    	include("inc/".$page.".php");
    }

?>

</td>

</tr>
</table>

Open in new window

0
 

Author Comment

by:brettsky07
ID: 33587009
page.php simply contains links at this point.. no style or content... originally it had text content so when the 'year' link was clicked it displayed the contents of page.php. Now it is just holding links. However, if there is a way I could do this all from one page that would be extremely helpful...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:brettsky07
ID: 33587156
What I am looking to achieve is a navigation hierarchy (vertical sidebar with links) where the user will click on "year" link and "month" links will appear. Than when the user clicks a month that months content will appear...

Ex. http://www.gomedia.us/contact/
- click on Work and "subnavigation" appears below... click on a sub link... that content is shown.
0
 

Author Comment

by:brettsky07
ID: 33587161
Note: just a basic version of this without the animation is what I am after.
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 33588410
That kind of menu is normally done in javascript since it needs to be executed in the browser.  PHP is used when the content of the second or third level needs to be looked up in a database.  Here's one source of menus: http://www.dynamicdrive.com/dynamicindex1/index.html
0
 
LVL 20

Expert Comment

by:virmaior
ID: 33588524
usually for this you would style a list:
<style type="text/css">
.menu_ul_label { font-weight:bold }
.menu_ul {

 display: block; padding: 0px; margin-left: 10px; list-style: none; 
}
.menu_ul li {
display: block; padding: 0px 0px; margin: 0px; list-style: none; 
} 
</style>

<ul class="menu_ul">
<li><div class="menu_ul_label">Part 1</div>
  <ul class="menu_ul">
    <li>link one</li>
    <li>link two</li>
   </ul>
</li>
<li><div class="menu_ul_label">Part 2</div>
  <ul class="menu_ul">
    <li>link three</li>
    <li>link four</li>
   </ul>
</li>
...
</li>

Open in new window

0
 

Author Closing Comment

by:brettsky07
ID: 33588821
Thanks. I think I will stick with the php I have and use an accordian style nav column for the rest.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now