Solved

PHP Dynamic Navigation

Posted on 2010-09-01
9
419 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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
 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to create an extensible mechanism for linked drop downs.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

832 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