开发者

Get request info in view helper

开发者 https://www.devze.com 2022-12-16 04:32 出处:网络
Is it possible in Zend View helper (extends Zend_View_He开发者_JS百科lper_Abstract) get info about module/controller/action in which that helper was called ?Yes. You can use Zend_Controller_Front::get

Is it possible in Zend View helper (extends Zend_View_He开发者_JS百科lper_Abstract) get info about module/controller/action in which that helper was called ?


Yes. You can use Zend_Controller_Front::getInstance() within view helpers. So you could do something like this:

class App_Helper_DoSomething extends Zend_View_Helper_Abstract
{
    public function doSomething()
    {
        return Zend_Controller_Front::getInstance()
            ->getRequest()
            ->getControllerName();
    }
}

Which will print the current controller name when called in your view with:

echo $this->doSomething();
0

精彩评论

暂无评论...
验证码 换一张
取 消