Sorry this is a long post, in short: Is it possible to get PHP to identify the folder a page sits in?
I have a header.php page which has tabs on it as a menu system, this page is loaded into all other PHP pages when they load. When a person goes to the different areas (i.e. Information, Search) the tab for the area needs to update so that it is highligted.
Rather than having the coding on every page and setting the tabs to update manually, does anyone know of a way to get the master page, which the header is loaded into, to be able to detect which folder it sits in (i.e. /information/ or /search/ ) which I can then use to update the header page with, reflecting which tab should be selected.
The trouble with putting the header page into each page seperatly, rather than loading from an external document, is that when i make changes I have to update every page on the site!!!
Any advice would be really appreciated, sorry for the long post!
Using PHP to identify the folder the page is in?
Moderator: General Moderators
Code: Select all
dirname($_SERVER['PHP_SELF']);Thank you for your reply, perfect!
Say I have this code:
Which actually equalled /en/people/information/group/ - what would be a method of searching the directory tree for "people"?
I have used PHP searches before, but not for some time - sorry to go back to basics!
Say I have this code:
Code: Select all
$folder = dirname($_SERVER['PHP_SELF']);I have used PHP searches before, but not for some time - sorry to go back to basics!
Yes thats right, would it inolve a LIKE search, although I only know how to do this when looking through a database for records.
I need something along the lines off:
When $folder contains 'people' $mainfolder="1"
//
When $folder contains 'information' $mainfolder="2"
And so forth, thanks for your time on this one!
I need something along the lines off:
When $folder contains 'people' $mainfolder="1"
//
When $folder contains 'information' $mainfolder="2"
And so forth, thanks for your time on this one!