Thanks you, Mathew, I'll try!

Matthew Weier O'Phinney-3 wrote:
> 
> -- minglee <[EMAIL PROTECTED]> wrote
> (on Tuesday, 31 July 2007, 09:49 AM -0700):
>> 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/.
> 
> Helper classes expect a class *prefix*. Since yours does not have a
> prefix, that's what's causing the issue. Try the following:
> 
>   * Rename your helper to 'My_Help'
>   * Then register it:
>   
>         Zend_Controller_Action_HelperBroker::addPath($path, 'My');
>     
>     This tells the helper broker to look for them at the given path, and
>     assume that they have the prefix 'My_' (you don't need the
>     underscore when registering; it does that for you). 
> 
>   * In your action controller, try this:
>     
>         $helper = $this->_helper->getHelper('help');
> 
>     This will look for action helpers that end with 'Help', and likely
>     find your 'My_Help' class and create that helper.
> 
>> 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.
>> 
> 
> -- 
> Matthew Weier O'Phinney
> PHP Developer            | [EMAIL PROTECTED]
> Zend - The PHP Company   | http://www.zend.com/
> 
> 

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

Reply via email to