I'm creating a site using PHP
with includes
for better maintenance, however I'm having a problem.
If I used only HTML
this problem would not be occurring, as I'm using includes
to pull menu , I can not add a class to all pages.
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 suppose that I'm on the page index.php
so you have to add a class to <li>
Home .
For a better understanding, see:
As it is if I'm on the index.php page ):
HowdoIgetifI'montheindex.phppage(right):
Example:
If the person is on the page
index.php
has to be added to the active class in<li>
Home .If the person is on the page
sobre.php
it has to be added to the active class in<li>
About and so on.
In case you have to add a class, so, eg:
<li class="ativo">
<a href="index.php">Início</a>
</li>
Note: This reminded me a lot of permalink
function of Wordpress.
An example is the WP Total site: link
When I enter the site, the name Início
in the menu is orange.
IfIaccessthepageabout,theAboutnameinthemenubecomesorange.