I have a pretty basic website started. However, since I know I will have to add/change/delete certain parts of the menu, I decided to make the menu an included PHP file.
However, I also have set up a "current" id for the anchor tag. Normally it would be easy, and I would just add "<a href="somepage.php" id="current">". However, since it is an included page, I was wondering if I could set it up to, depending on which page you are at, add the id="current" dynamically, using PHP of course.
Would I do this on the menu.php file or somewhere on the page where I call the 'include' function?
Thanks. Any help is appreciated,
Antoine
Dynamically change anchor id based on current page.
Moderator: General Moderators
Re: Dynamically change anchor id based on current page.
rememeber that if you include a page , you have access to all the variables declared in the parent page. So you can just assume that a certain variable is defined before including a file
then in menu.php you just use the current_page variable
Code: Select all
$current_page = 'whatever';
include 'menu.php';
Re: Dynamically change anchor id based on current page.
Thanks!
I had tried that earlier and it didn't work, but I just discovered I used " instead of' '.
Thanks for the help!
I had tried that earlier and it didn't work, but I just discovered I used " instead of' '.
Thanks for the help!