2
I’m creating a website using PHP with includes for better maintenance, but I’m having a problem.
If I only used HTML this problem would not be occurring, because as I am using includes for pull up the menu, I can’t add a class to every page.
I have a menu that uses code like this:
<ul id="menu" class="clearfix">
<li>
<a href="index.php">Início</a>
</li>
<li>
<a href="sobre.php">Sobre</a>
</li>
<li>
<a href="contato.php">Contato</a>
</li>
</ul>
Now let’s assume I’m on the page index.php then a class has to be added to the <li> Beginning.
For a better understanding, see:
As is if I’m on the index.php page (wrong):

How it has to look if I’m on the index.php page (right):

Example:
If the person is on the page
index.phphas to be added to the class (active) in the<li>Beginning.If the person is on the page
sobre.phphas to be added to the class (active) in the<li>About and so on.
In case it has to be added a class, getting like this, ex:
<li class="ativo">
<a href="index.php">Início</a>
</li>
Note: This reminded me a lot the function permalink wordpress.
An example is the WP Total site: http://www.wptotal.com/
When I enter the site, the name Início on the menu turns orange.

If I access the page about, the name About on the menu turns orange.

In all . php you have the menu (repeated)?
– Jorge B.
Yes @Jorgeb I use includes on all pages to pull the file
menu.phpcontaining the menu code inside.– Alexandre Lopes
It can be in jQuery?
– Marcelo Aymone
Hello @Marceloaymone thanks for trying to help, but I believe that via Javascript is not the best solution, because via PHP is easier because the page is already rendered, via Js need to wait for the upload.
– Alexandre Lopes