Navigation include for all site directories


Posted on 16th Feb 2014 07:03 pm by admin

Hi,

I need a navigation include that can deal with directories at different levels on a site. All I can seem to find are the basic includes for files all in the same directory. This doesn't work for me because as soon as you navigate to a page in a nested directory the relative links don't work.

Is the only option for me to use absolute links? This would cause difficulty as I would need different addresses to achieve the same result on the testing server and remote site.

I also need to be able to identify the current page to style the link. At the moment I am using the code below which is fine whilst everything is in the same directory but introduce nested directories and some links will be reachable with just the $base. But only as long as current page and destination page are in the same directory.

Code: $base=basename($_SERVER['PHP_SELF']);
$menu=preg_replace("|<li><a href="".$base."">(.*)</a></li>|U", "<li class="current">$1</li>", $menu);
echo $menu;
I would greatly appreciate your help

No comments posted yet

Your Answer:

Login to answer
270 Like 40 Dislike
Previous forums Next forums
Other forums

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
what is wrong with this

Code: [Select]<?php
if ($_SERVER['HTTP_REFERER'])
{

Async WSAConnect failed on XP with error code = 2 ("File not found")
Hi all,

I have very strange bug, please help me if you can.

It is reproduced o

have trouble in a if condition
The if below is working ok, it check when indexes, name, zipcode and state are empty.
Code: &

problem with GROUP BY and ORDER BY
i usually use this query to display the last 10 entries from a sql table:

Code: $query = &quo

single page with referrer to show correct page
I have a simple website with a couple of different pages. I would like to be able to in a div tag w

BackButton Behaviour in AJAX
I have an ASPX Page AJAX Enabled!The page has a gridView and a DDL for filtering on it. The Gridview

LIMIT $start, 10... how to pass last value queried into next page with GET??
Ok I know how to display the first or last 10 results of a query...

$result = mysql_query(&q

What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is goin

a multi dimensional array with for each
hi, I have been asked to write an array, I have Zone 2,3,4,5,6,7,8 each zone has 3 sections of weigh

login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash