-- Julian Davchev <[EMAIL PROTECTED]> wrote
(on Wednesday, 19 March 2008, 05:59 PM +0200):
> Is it just me or you sent same mail 3 times.
> Ok, extending View is definately not a good idea.
>
> at worst you should do Zend_Registry::get('Zend_Translate');
>
>
> other thing you could do is have one common helper that all your view
> helpers extend
> and on init() this helper sets Zend_Translate...so that each view helper
> out have it.
>
> Might be better approach...this just comes to mind now.
I've written with a better approach: add a setView() accessor to the
helper that sets the view in a public view property. This is the
documented way to have your view helpers view aware.
> rcastley wrote:
>> Hi All,
>>
>>
>> Hoping someone can help me out here.
>>
>> I have just upgraded to ZF 1.5 and have discovered that Zend_Translate can
>> be made available to views by setting a registry entry and then using
>> $this->translate('langString') in my views.
>>
>> I have created some helpers that I include in my views using e.g.
>>
>> echo $this->myHelper();
>>
>> In my Helper I have the following:
>>
>> class Zend_View_Helper_MyHelper
>> {
>> public function myHelper()
>> {
>> $s = "Hello World!";
>> $s .= $this->translate('myString');
>>
>> return $;
>> }
>> }
>>
>> When this is run I will get an error in my view stating: Call to undefined
>> method Zend_View_Helper_MyHelper::translate() ...
>>
>> Now, I can seem to fix this by changing the class line above to read:
>>
>> class Zend_View_Helper_MyHelper extends Zend_View
>>
>> My question is, is this correct or should I be going about things a
>> completely different way?
>>
>> Many thanks in advance.
>>
>> - Robert
>>
>
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/