learning_brain
New Member
- Messages
- 206
- Reaction score
- 1
- Points
- 0
This is a little more complex than the title suggests.
I have a menu system in a header - which is, as you might expect, an include file.
http://www.donbur.co.uk/eng/css/csstest.php
Within the menu, I have options for making the <dd> elements with a "current" class or not...
So... my first step was to get the current url.
All pretty basic stuff - provided it resides in the original file - not the include file (which would have been more convenient). Testing fro the main file, this works a treat.
Then a simple line in the include...
Theoretically, this would then pick up that its the same page and change the class to "current". The css takes care of the rest.
NOPE...
For some unknown and frustrating reason, the $currentFullURL variable in the main file is not passing to the include. If I try to echo this variable from the include (anywhere in the include), it's an empty variable..... why??????
I have looked at putting it into a Session variable and also a $GLOBALS variable - all without success.
Am I missing something???
Rich
I have a menu system in a header - which is, as you might expect, an include file.
http://www.donbur.co.uk/eng/css/csstest.php
Within the menu, I have options for making the <dd> elements with a "current" class or not...
So... my first step was to get the current url.
PHP:
//obtain full current url
$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'];
$url = $_SERVER['REQUEST_URI'];
$currentFullURL = $protocol.'://'.$host.$url;
All pretty basic stuff - provided it resides in the original file - not the include file (which would have been more convenient). Testing fro the main file, this works a treat.
Then a simple line in the include...
PHP:
<dd <?php if($currentFullURL == "http://www.donbur.co.uk/eng/about/history.php"){?>class="current"<?php } ?>>
Theoretically, this would then pick up that its the same page and change the class to "current". The css takes care of the rest.
NOPE...
For some unknown and frustrating reason, the $currentFullURL variable in the main file is not passing to the include. If I try to echo this variable from the include (anywhere in the include), it's an empty variable..... why??????
I have looked at putting it into a Session variable and also a $GLOBALS variable - all without success.
Am I missing something???
Rich