Hi, 13sio
I did according to you told, but an error of "Action Helper find by name
'MyHelp' not found' occurred. 'MyHelp' is the name of helper class. I think
there is a path setting problem. What is your suggestion for my case? I put
MyHelp in /wwwroot/zf/application/helpers/.
Thanks a lot! 

13sio wrote:
> 
> Hi minglee,
> 
> For Zend_Controller_Action_HelperBroker::addPath(string $path, [string
> $prefix = 'Zend_Controller_Action_Helper']), the second argument is the
> prefix of the helpers.
> 
> In your case,
> Zend_Controller_Action_HelperBroker::addPath('./application/helpers/',
> 'MyHelper') means that the helper classes are hiding in
> /wwwroot/zf/application/helpers/, and are with prefix 'MyHelper'. For
> instance, /wwwroot/zf/application/helpers/SayHello.php
> 
> class MyHelper_SayHello extends Zend_Controller_Action_Helper_Abstract {
> //...
>   public function getMessage() {
>     return 'Hello';
>   }
> //...
> }
> 
> And we can invoke it as follows
> $message = $this->_helper->getHelper('SayHello')->getMessage();
> 
> Hope it helps.
> 
> 
> minglee wrote:
>> 
>> Hi, guys.
>> I wrote a helper class (extends Zend_Controller_Action_Helper_Abstract),
>> and put it in 'wwwroot/zf/application/helpers/', named as MyHelper.
>> Then I add
>> 'Zend_Controller_Action_HelperBroker::addPath('/zf/application/helpers/',
>> 'MyHelper');'  in init() method of my controller class, 
>> and called the helper using '$this->_helper->MyHelper($help);', but error
>> occurred showing 'cannot find the helper'. 
>> I tried path './application/helpers/' also, but failed.
>> I think it's a path error but how should I set the path? Or should put My
>> Helper in the same folder as the default ? Or should put the helper
>> registration in bootstrap file?
>> Could anybody answer my question?!
>> Thanks!
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Problem-with-ZF-helper-tf4168559s16154.html#a11928071
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to