zend-frameworkzend-viewzend-controller

How to call static view helper method in controller?


like in topic, I have two static method in view helper but when I try to call in controller action by

Zend_View_Helper_SomeHelper::firstStaticMethod();

I got error:

Warning: include_once(Zend/View/Helper/SomeHelper.php): failed to open stream: No such file or directory in /library/Zend/Loader.php on line 134 Warning: include_once(): Failed opening 'Zend/View/Helper/SomeHelper.php' for inclusion (include_path='/application/../library:/library:.:/usr/share/pear:/usr/share/php') in /library/Zend/Loader.php on line 134 Fatal error: Class 'Zend_View_Helper_SomeHelper' not found in /application/modules/default/controllers/Controller.php on line 174

Helper code:

class Zend_View_Helper_SomeHelper extends Zend_View_Helper_Abstract {
    //....//
    public static function firstStaticMethod(){
        //some code hear
    }
    public static function secoundStaticMethod(){
        //some code hear
    }
}

I need to use this method in helpers and action. any ideas?


Solution

  • Can you try this

    $viewHelperObj = $this->view->getHelper('SomeHelper');
    $viewHelperObj->secoundStaticMethod();