how can I get a reference to current Mage_Core_Controller_Varien_Action or decendant

邮差的信 提交于 2019-12-11 03:33:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!