Posts tagged with ‘view’

 

You know sometimes, in CakePHP’s views, it is useful to check what is the controller’s action. It is quite useful when it comes to implementing selected tabs.

You can use the following expression to get the action name from your view:

$this->controller->action

The following is a usage example:

<?php /* This is a view element file - nav_messages.thtml */ ?>
<?php $s = $this->controller->action; ?>
<ul class="generic_subtabs">
  <li class="<?php echo ($s==’messages_inbox’)?’selected’:” ?>" >
    <a href="#" title="Inbox">Inbox</a>
  </li>
  <li class="<?php echo ($s==’messages_sentbox’)?’selected’:” ?>">
    <a href="#" title="Sentbox">Sentbox</a>
  </li>
</ul>

“messages_inbox” and “messages_sentbox” is the name of the action (function) in my controller. (more…)

 

WordPress powered and Django inspired.
Love and elephants come after.
RSS: Posts and comments.