views:

26

answers:

1

Hi guys!

Im trying to detect wich controller Im am using or what controller Im on and then change my menu accordingly to the page Im on.

( Make a selection in the menu so the user can see were he is on the page! )

I really dont know what to write to check what its using...

<? if($this->url(array("controller" => "index", "action" => "index"), null, true)) {
    echo("LOL");
}
?>

I tried that but that stuff didnt work at all, I know its the wrong thing to use, so please help me =D

Best Regards,

Charlie

A: 

You can get Controller and Action name from the current Request object with getControllerName() and getActionName().

From your controller:

$controller = $this->getRequest()->getControllerName();
$action = $this->getRequest()->getActionName();
// set to View

From a ViewHelper

$front = Zend_Controller_Front::getInstance();
$controller = $front->getRequest()->getControllerName();
$action = $front->getRequest()->getActionName();
// do something with it
Gordon