问题
I need a reference to the "current" running action from the code of a block.
i.e. I have a $this which is a descendant of Mage_Core_Block_Template and I need a way to call methods on the an instance of Mage_Core_Controller_Front_Action for the current request.
I hope this was clear enough.
回答1:
Couple of things come to mind:
Mage::app()->getFrontController()
Also every block since all of them extends the Mage_Core_Block_Abstract have the following method:
$this->getRequest()
This return a Mage_Core_Controller_Request_Http which contains various methods like getControllerModule() or getModuleName().
HTH
回答2:
Found out that I can use $this->getAction()
来源:https://stackoverflow.com/questions/5002602/how-can-i-get-a-reference-to-current-mage-core-controller-varien-action-or-decen