• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 444
  • Last Modified:

PHP Dynamic Navigation

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
brettsky07
Asked:
brettsky07
  • 4
  • 2
  • 2
  • +1
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
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
 
drakesheCommented:
what is inside page.php?
0
 
virmaiorCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
brettsky07Author Commented:
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
 
brettsky07Author Commented:
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
 
brettsky07Author Commented:
Note: just a basic version of this without the animation is what I am after.
0
 
Dave BaldwinFixer of ProblemsCommented:
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
 
virmaiorCommented:
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
 
brettsky07Author Commented:
Thanks. I think I will stick with the php I have and use an accordian style nav column for the rest.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now