All writing

Retrieve Current Module/Controller/Action inside View Script / Layout Script

Before I forget to do this again I’m going to make a post on how to get the current Module, Controller, and Action while inside a View Script or Layout Script.

Here is the most correct way to do it:

$front = Zend_Controller_Front::getInstance();
$request = $front->getRequest();

$module = $request->getModuleName();
$controller = $request->getControllerName();
$action = $request->getActionName();

Now, here is the incorrect way I attempted to do this the first time:

$front = Zend_Controller_Front::getInstance();
$request = $front->getRequest();

$module = $request->getParam('module');
$controller = $request->getParam('controller');
$action = $request->getParam('action');

I found some odd behavior because sometimes while in the default module it would return default, but other times it would return a null. I’m not sure if this is a bug or not, but the most sure way to retrieve the desired result is using the appropriate methods of getModuleName(), etc.

Hope this helps someone out there!

Sheet
A-3 · Detail
Drawn
Utah
Scale
1:1
Rev
2026