In Zend Framework 2 I would like to get the current action from the layout html file, to know which menu is active (for css purposes).
Has anybody information how can I do it?
I tried many possible solutions but all of the was useless.
Thanks a lot!
Asked
Active
Viewed 670 times
0

Gabor Varga
- 95
- 1
- 11
2 Answers
0
Take a look into stack overflow
you should put your already tested code too.

Community
- 1
- 1

Remi Thomas
- 1,528
- 1
- 15
- 25
-
The second option is working. To use it permanently I combined it with overidden onDispatch method shown in next answer. – Gabor Varga Nov 06 '13 at 20:21
-
1So the solution based on Remi's second link: `public function onDispatch(MvcEvent $e) { $this->layout()->action = $this->params("action"); return parent::onDispatch($e); }` – Gabor Varga Nov 06 '13 at 20:29
0
So based on Remi's second link the full code is:
public function onDispatch(MvcEvent $e) {
$this->layout()->action = $this->params("action");
return parent::onDispatch($e);
}
With this always can be send any data for layout. But only for layout.

Gabor Varga
- 95
- 1
- 11