1

Most of the views in the app render a default layout. It also has a navigation menu which purpose is to navigate users through the controllers and it looks like this:

<li class="dashboard"><?php echo $this->Html->link('dashboard', array('controller'=>'events', 'action'=>'dashboard'))?></li>
<li class="users"><?php echo $this->Html->link('users', array('controller'=>'users', 'action'=>'index'))?></li>
<li class="dates"><?php echo $this->Html->link('dates', array('controller'=>'dates', 'action'=>'index'))?></li>
<li class="projets"><?php echo $this->Html->link('sager', array('controller'=>'projcets', 'action'=>'index'))?></li>

Based on which controller had rendered the layout, I would like to add active to <li class=""> so I could style that particular element differently.

Any help or guidance on how to get to know which controller had rendered the layout is much appreciated.

Domas
  • 1,133
  • 4
  • 18
  • 46
  • 3
    Probably a duplicate of this question: http://stackoverflow.com/questions/13034267/in-viewcakephp-the-proper-way-to-get-current-controller – cowls Sep 04 '14 at 07:37

1 Answers1

2

Use $this->request->controller to get the current controller.

Use $this-action to get the current action.

Use $this->request->method() to get the current method.

munsifali
  • 1,732
  • 2
  • 24
  • 43