-- Dimitri van Hees <[EMAIL PROTECTED]> wrote
(on Wednesday, 06 August 2008, 05:34 PM +0200):
> i've been trying out Zend_Dojo today, but to me one thing is still not
> clear. let me explain the situation. i have one layout file
> (default.phtml) in which i have to include the following code:
>
> if ($this->dojo()->isEnabled()):
> $this->dojo()->setLocalPath('/js/dojo/dojo.js')
> ->addStyleSheetModule('dijit.themes.tundra');
> echo $this->dojo();
>
> my problem is simple: on pages without javascript but with the same
> layout, i get a fatal error because $this->dojo() isn't there. i'm not
> sure whether Zend_Dojo::enableView($view) does this for pages where i
> use dojo, in that case perhaps doing this in my bootstrap file is the
> solution. however, as it is not needed in 95% of my pages, this doesn't
> look right to me.
>
> any suggestions anyone? and is setting $this->dojo()->enable() manually
> right in case i want to use my own javascript instead of zf's generated
> js?
You should call Zend_Dojo::enableView($view) in your bootstrap,
regardless of whether your given action will be utilizing it. By
default, the dojo() view helper is still disabled -- it is only when you
actually manually enable it or utilize dijit form elements that it will
be marked as enabled.
The dojo() view helper sets up your dojo environment for you -- so if
your own JS depends on dojo, you should definitely enable it in such
situations using enable() -- otherwise dojo.js will not be included on
your page, and you'll run into all sorts of other issues.
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/