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.

Did you know?Explore Trending and Topic pages for more stories like this.
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

Small problem with image resize script
Hi!

I am a little bit new to php and I have an issue installing an image resize script I down

Error Messaging not working
I changed the way my form tells the user of an error. But I can't seem to get it to work properly.

If statement help please.
Hello on my site I have 2 content boxes. 1 is for the main content (which is the biggest one) and th

Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and

Converting RGB values to HEX
Code: <?PHP

$file_handle = fopen("colors/rgb.csv", "r");

wh

Pro-rata Billing in Periodic Billing for Rental
Hi guys,

We have a situation, where a rental contract starts at the mid of the month say

Join Query Help
Hi all,

I am having problems with the below code, which we shall call 'my first join query'!

HTML form problem
Ive made a form to that i want to send to my email via PHP. but when it send only the name's etc sen

Advice on how to delete a mysql row using my form
Hi,

I am very new to php and am struggling to work out how to delete a portfolio item (a row

FILTER_CALLBACK -- Files?
Hi All,

I'm using the php filter functions to validate my form data. For custom filters, I'm

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