-- Ian Warner <[EMAIL PROTECTED]> wrote
(on Sunday, 20 January 2008, 07:54 PM +0000):
>
> $view = new Zend_View();
>
> // Add /other/path/to/helpers with class prefix 'Your_View_Helper'
>
> $view->setHelperPath('D:\AWebEnvironment\htdocs\Site_Template\library\Zend\View\Helper',
>
> 'Common_Components');
>
> I have tried the above and also with addHelperPath and still no luck -
> tried this on my ubuntu machine also.
>
> whats the naming convention for helpers, the docs dont give any advice on
> what the actual file name should be
Not to be mean, but they *do* spell it out, several times:
http://framework.zend.com/manual/en/zend.view.helpers.html
Second paragraph:
"A helper is simply a class. Let's say we want a helper named
'fooBar'. By default, the class is prefixed with 'Zend_View_Helper_'
(you can specify a custom prefix when setting a helper path), and
the last segment of the class name is the helper name; this segment
should be TitleCapped; the full class name is then:
Zend_View_Helper_FooBar."
And further in that same page:
37.4.3. Writing Custom Helpers
Writing custom helpers is easy; just follow these rules:
* The class name must, at the very minimum, end with the
helper name itself, using CamelCaps. E.g., if you were
writing a helper called "specialPurpose", the class name
would minimally need to be "SpecialPurpose". You may,
and should, give the class name a prefix, and it is
recommended that you use 'View_Helper' as part of that
prefix: "My_View_Helper_SpecialPurpose". (You will need
to pass in the prefix, with or without the trailing
underscore, to addHelperPath() or setHelperPath()).
There's also one other place it's mentioned, in the section detailing
helper paths.
So, in your example, if you have the prefix "Common_Components" as your
view helper class prefix, and your library code is in
"D:\AWebEnvironment\htdocs\Site_Template\Library\', the most logical
place to put these helpers would be in the "Common\Components\"
subdirectory of that location, and you would then add the following path
to your view helper paths:
$view->addHelperPath('D:\AWebEnvironment\htdocs\Site_Template\Library\Common\Components\',
'Common_Components');
If you then have a "foo" helper, it would be in the 'Foo.php'
file in that directory, and have the class name Common_Components_Foo.
Hope that helps.
> Matthew Weier O'Phinney wrote:
>> -- Ian Warner <[EMAIL PROTECTED]> wrote
>> (on Sunday, 20 January 2008, 01:00 PM +0000):
>>> Sorry I should have said that I tried that also.
>>>
>>> Still no luck
>> I use code like the following code regularly:
>> $view->addHelperPath('path/to/My/View/Helper', 'My_View_Helper');
>> and it works fine. Can you send me the code you used when trying
>> addHelperPath()?
>>> Pieter wrote:
>>>> Hi Ian,
>>>> I think that you should use the $view->addHelperPath() function.
>>>> Regards,
>>>> Pieter Kokx
>>>> Ian Warner schreef:
>>>>> hi
>>>>>
>>>>> I am having real trouble trying to set helper paths.
>>>>>
>>>>> I assume I can place this anywhere in my code structure - I have tried
>>>>> in bootstrap / controllers and a few other places
>>>>>
>>>>> Pathing - I think I have this correct below though I although I have
>>>>> changed this any which way but loose.
>>>>>
>>>>> $view = new Zend_View();
>>>>>
>>>>> // Add /other/path/to/helpers with class prefix
>>>>> 'Your_View_Helper'
>>>>>
>>>>> $view->setHelperPath('D:\AWebEnvironment\htdocs\Site_Template\library\Zend\View\Helper',
>>>>>
>>>>> 'Common_Components');
>>>>>
>>>>> I have this when I throw the stack in the view.
>>>>>
>>>>> [_path:private] => Array
>>>>> (
>>>>> [script] => Array
>>>>> (
>>>>> [0] => sites\admintrianglesolutions\views\scripts\
>>>>> )
>>>>>
>>>>> [helper] => Array
>>>>> (
>>>>> [0] => Array
>>>>> (
>>>>> [prefix] => Zend_View_Helper_
>>>>> [dir] =>
>>>>> sites\admintrianglesolutions\views\helpers\
>>>>> )
>>>>>
>>>>> [1] => Array
>>>>> (
>>>>> [prefix] => Zend_View_Helper_
>>>>> [dir] =>
>>>>> D:\AWebEnvironment\ZendFramework-1.0.3\library\Zend\View\Helper\
>>>>> )
>>>>>
>>>>> )
>>>>>
>>>>>
>>>>>
>
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/