I am working with PHP, on my system I have a Sidebar that works without problems. But what it lacks and I am trying to do, is that when it is positioned on a page, the current position is highlighted in the sidebar.
In my page menu.php I create the sidebar with its options:
<ul>
<li>
<a href="admin.php">
<i class="glyphicon glyphicon-home"></i>
<span>Inicio</span>
</a>
</li>
<li>
<a href="pasantia.php">
<i class="glyphicon glyphicon-folder-open"></i>
<span>Mis Solicitudes</span>
</a>
</li>
</ul>
Later on the header.php page I add the sidebar
<div class="sidebar">
<?php include_once('menu.php');?>
</div>
And in the rest of the pages I call the header.php
<?php include_once('layouts/header.php'); ?>
What I have tried to do but it has not worked for me is to add the following code in menu.php
<li <?php if($_SERVER['SCRIPT_NAME']=="/admin.php") { ?> class="active_nav" <?php } ?>>
<a href="admin.php">
<i class="glyphicon glyphicon-home"></i>
<span>Inicio</span>
</a>
</li>
In my css code create the style:
.active_nav {
position: fixed;
z-index: 10;
left: 0;
top: 0;
padding: 65px 0 0;
height: 100%;
width: 250px;
background: #d80e0e;
border-right: 1px solid #014185;
text-align: center;
}
I hope someone can guide me or point out what I'm doing wrong.
I solved it, adding the following function:
I define the CSS style:
And finally I add the style to the li