title: How do I add active class in menu link using CakePHP?
body: <p>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?</p>
  
  <p>For identify link I am using:</p>
  
  <pre><code>&lt;li class="&lt;?php echo (!empty($this-&gt;params['action']) &amp;&amp;   ($this-&gt;params['action']=='view') )?'active' :'inactive' ?&gt;" &gt;
  </code></pre>
  
  <p></li></p>
  
  <p>Here, the different controller I have has the same action link in <strong>view</strong>.  How do I control this same name?</p>
  
  <pre><code>            &lt;nav class="top-bar"&gt;
                  &lt;ul class="title-area"&gt;
                      &lt;li class="name"&gt;&lt;/li&gt;
                      &lt;li class="toggle-topbar menu-icon"&gt;
                          &lt;a href="#"&gt;&lt;span&gt;Menu&lt;/span&gt;&lt;/a&gt;
                      &lt;/li&gt;
                  &lt;/ul&gt;
                  &lt;section class="top-bar-section"&gt;
                      &lt;ul class="left"&gt;
                          &lt;li&gt;
                              &lt;?php
                              echo $this-&gt;Html-&gt;link('Home', array('controller' =&gt; 'pages', 'action' =&gt; 'index'));
                              ?&gt;
                          &lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Destinations&lt;/a&gt;&lt;/li&gt;
                          &lt;li &gt;
                              &lt;?php
                              echo $this-&gt;Html-&gt;link('Hotels', array('controller' =&gt; 'hotels', 'action' =&gt; 'view'));
                              ?&gt;
                          &lt;/li&gt;
                          &lt;li &gt;
  
                              &lt;?php
                              echo $this-&gt;Html-&gt;link('Packages', array('controller' =&gt; 'packages', 'action' =&gt; 'view'));
                              ?&gt;
                          &lt;/li&gt;
                          &lt;li &gt;
                              &lt;?php
                              echo $this-&gt;Html-&gt;link('Search', array('controller' =&gt; 'hotels', 'action' =&gt; 'search'));
                              ?&gt;
                          &lt;/li&gt;
                          &lt;li&gt;
                              &lt;?php
                              echo $this-&gt;Html-&gt;link('Booking', array('controller' =&gt; 'reservations', 'action' =&gt; 'reservation'));
                              ?&gt;
                          &lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Trains&lt;/a&gt;&lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/section&gt;
              &lt;/nav&gt;
  </code></pre>