Solved

PHP Dynamic Navigation

Posted on 2010-09-01
9
387 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 82

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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 82

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
This article discusses four methods for overlaying images in a container on a web page
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

708 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

16 Experts available now in Live!

Get 1:1 Help Now