2
On my php pages I use a include to call a file that contains my menu:
<?php include('../../sidebar-menu.php'); ?>
Menu file:
<ul class="sidebar-menu" id="nav-accordion">
<?php
foreach ($lista as $key => $value) {
echo '<li class="mt">
<a href="/view/DadosIndicadores/index.php?id_tipo='.$lista[$key]['id'].'">
<i class="fa fa-bar-chart-o"></i>
<span>'.$lista[$key]['nome'].'</span>
</a>
</li>';
}
?>
</ul>
How do I insert the active class only in the accessed menu?
Here the use of FILE didn’t bring the file name of the page, but rather brought the file name of the menu sidebar-menu.php. It’s not quite this name that should appear, correct?
– Rodrigo Segatto
I forgot you were doing include! Tries to create a variable in the header of the accessed page file, which saves what is in constant _FILE_, before you call include, and then see if include can read this variable... If it works, then just change the _FILE_ if’s. Anyway, why don’t you study using the Twig as a template system?
– Heitor Silva