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.
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