Reputation: 9340
I have a view that could be called from any of 3 actions from one controller. But, that view should be slightly different depending on what action caused it (it should display 3 icons or 2 or one depending on action called). Can I check in the view what action caused it so I can use if statement to check whether display each icon or not?
Thank you.
Upvotes: 0
Views: 269
Reputation: 5483
Of course, you can pass action
value directly to the view:
$this->template->action = Request::current()->action();
But View should not know anything about Request
properties, its a Controller logic. I suggest you to pass special flags from your actions:
public function action_show1()
{
// show only one icon
$this->template->icons = array('first');
}
public function action_show2()
{
// show another two icons
$this->template->icons = array('second', 'third');
}
public function action_showall()
{
// show all icons
$this->template->icons = array('first', 'second', 'third');
}
Or set special flag (variable) for every icon.
Upvotes: 3