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

Problem with Sending Mail by PHP
hello all,
I m new to php, can u plz provide me the code to send mail by php having CAPTC

calculator
I can't figure out why this code doesn't work. No error messages. Page loads.

Code: <

Batch update record with Pagination
Hoping someone can help me with this issue I'm having, im trying to batch update records from a resu

start new row of pictures
on my site www.budstreasureauctions.com there is a featured auctions box that users will pay to get

retrieving images from mysql database using php
So I've been trying to figure out how to store images in a mysql database, and as far as i can tell

mod_rewrite.c on windows ??
why it's not working on windows while it's working on other hosts???

this is the code i got

Do While statement
hi guys,

This may sound trivial but im new to php and as part of an assignmenti have to const

mysql select with $_get ?
Hi, i have this code:
Code: // If char id is 0 and character dont exist do:
if ($_GET["id

Echoing ASCII code
I have a php page that splits a string into chars and then echoes the ASCII code for each char. I'm

Running External Scripts
I am very new to PHP and am not even sure what I'm asking is possible. I have just installed mediaW

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