I have a page in my default.ctp file in which I want to add 'active' class on links. How can I identify the current URL of the page and then apply the class on link?
For identify link I am using:
<li class="<?php echo (!empty($this->params['action']) && ($this->params['action']=='view') )?'active' :'inactive' ?>" >
Here, the different controller I have has the same action link in view. How do I control this same name?
<nav class="top-bar">
<ul class="title-area">
<li class="name"></li>
<li class="toggle-topbar menu-icon">
<a href="#"><span>Menu</span></a>
</li>
</ul>
<section class="top-bar-section">
<ul class="left">
<li>
<?php
echo $this->Html->link('Home', array('controller' => 'pages', 'action' => 'index'));
?>
</li>
<li><a href="#">Destinations</a></li>
<li >
<?php
echo $this->Html->link('Hotels', array('controller' => 'hotels', 'action' => 'view'));
?>
</li>
<li >
<?php
echo $this->Html->link('Packages', array('controller' => 'packages', 'action' => 'view'));
?>
</li>
<li >
<?php
echo $this->Html->link('Search', array('controller' => 'hotels', 'action' => 'search'));
?>
</li>
<li>
<?php
echo $this->Html->link('Booking', array('controller' => 'reservations', 'action' => 'reservation'));
?>
</li>
<li><a href="#">Trains</a></li>
</ul>
</section>
</nav>