0

I am try to use helperClass in Zend_Layout options. I create a class:

class Helper_Testi extends Zend_Controller_Action_Helper_Abstract{

    public function init(){
        echo "111111111";
        $this->fff = 'hello from Helper';
    }

    public function getMessage(){
        echo "==============";
        return "message";
    }
}

and in Bootstrap.php try add it to Zend_Layout:

$options = array('layout' => 'layout','helperClass'=>'../application/controllers/helper/Testi');
$layout = new Zend_Layout();
$layout->startMvc($options);

But when I reload browser I see Exception:

Fatal error: Uncaught exception 'Zend_Exception' with message 'File "../application/controllers/helper/Testi.php" does not exist or class "../application/controllers/helper/Testi" was not found in the file'

What I do wrong? Help me please.

Glen Solsberry
  • 11,960
  • 15
  • 69
  • 94
Eugene
  • 1,690
  • 3
  • 16
  • 30

2 Answers2

0

You need place your helper class in correct place.

E.g. in my bootsrap there are such lines:

protected function _initViewHelpers() {
    $this->bootstrap('layout');
    $layout = $this->getResource('layout');
    $view = $layout->getView();

    $view->addHelperPath('Icc/View/Helper' , 'Icc_View_Helper');
}

And helper files will be located in this folder: Icc\View\Helper\


Edit:

E.g. I have file FormDropdown.php with such content:

class Icc_View_Helper_FormDropdown extends Zend_View_Helper_Abstract {
    function formDropdown($name = '')
    {
       return "<select name='$name' id='$name'></select>";
    }
}

In view I can use this helper in this way:

    <?=$this->formDropdown('icc_info_salutation')?>
Andron
  • 6,413
  • 4
  • 43
  • 56
  • My helper class located in application/controllers/helper/. File name Testi.php, classname Helper_Testi. I need to add helper class to layout. For example helper generate data which changed after reloading page (for example time). – Eugene Jul 12 '11 at 15:23
  • My helper classes are located in `library/Icc/View/Helper` and these helpers can be used in layouts too. – Andron Jul 12 '11 at 15:44
0

Try to use APPLICATION_PATH constant in your path

Vyacheslav Loginov
  • 3,136
  • 5
  • 33
  • 49