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

Multi-image upload problems
Lets see if I can get some help on this one. Can anyone show me what I am doing wrong here. I'm just

multipart emiail forms
Hi All,

I am new to the boards and I've been working on a form (which is rather massive, imo

some questions
Hello,

I am looking for the answers for following questions:

1) Does PHP support overl

MS Access data into a html table
Hi everyone, I am quite a novice at php but I have created some helpful scripts that fetch data
f

Uploading Filetypes and placing them in seperate folders.
Hello,

first post , and asking for help im afraid. Very new to PHP, was making good progress

PHP Error
On my .php page I have a drop down box that has several names in it. When a user clicks the name &am

Transform value 0 in no and 1 in yes help needed
Hello,
I have this in the table: "value" type int 0 to represent false and 1 to represe

ob_ dynamic content
i was wondering about the potential to use ob to create a <div then remove it when the page

Need help with a mail notify function
I was tasked with setting up a site that's been prewritten. The site is basically a form that captur

Hit counter updating once per IP - IP HIT COUNTER
I have a hit counter, for the amount of views on a tutorial.
It'll do the query and then do..

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