I have a nav-bar with 3 link's. I used to keep the navbar within my 3 pages but someone suggested to use one navbar.php with that navbar code and include that file within all other files that use the navbar. So, less code, same result. And it works.
However, I was using aria-current="page" to highlight the link on the active page. But now that doesn't work anymore.
I found some similar pages with that question but it puzzles me. I am relatively new to all this so I hoped one could make it not only clear but crystal-clear to me.
I found this page : PHP Pass variable to next page
and so I used this code already to get info to navbar.php. (https://i.stack.imgur.com/ne5FI.png)
So , all things start on my index.php page where I use a navbar.php which contains my navbar. I can move to page 'about', 'portfolio' or 'contact' with one of the three links provided in navbar.php. On index.php none of the three links are highlighted of course because I'm not on one of those pages.
Now, when I am going to page 2 'about'. I want to give that info "$active_var=2" into navbar.php which will return a different outcome on the highlight of a 'href' with aria-current="page". The link 'about' will be fatter.
Same for the other pages.
I think i need to declare the variable in the navbar.php only. and then give a value when clicking on a link. That info will go to the corresponding page ex. about.php but that i'm not sure.
Here is my navbar code :
I left the code for the link to about.php like it was and changed the code for the other two links like I think they should be, but it doesn't work. enter image description here
I hope I was clear enough myself in my question.
tried inserting info from a variable but don't see how because I use a php with a include navbar.php which needs info from the parent php. I might not understand which page needs which var info. So I am on index.php with 3 links to other php's which all have the include navbar.php that has the code for making the links and highlighting the current page.