-- Guillaume Oriol <[EMAIL PROTECTED]> wrote
(on Wednesday, 01 October 2008, 07:45 AM -0700):
> 
> In some pages (where I put forms), I want to user Dojo forms. For this
> reason, I put Zend_Dojo::enableView($this->view); in that controller's
> actions.
> And I extend my form from Zend_Dojo_Form.
> 
> In my layout, I've added :
> <?php
> if ($this->dojo()->isEnabled()) {
>   $this->dojo()->setLocalPath($this->staticUrl('js/dojo/dojo.js'))
>                ->addStyleSheetModule('dijit.themes.tundra');
>   echo $this->dojo();
> }
> ?>
> 
> And in my bootstrap:
> $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
> 
> 
> Now, I get in every page (and not only where I activated Dojo in my action)
> that HTML code:

A couple of things.

First, calling Zend_Dojo::enableView($view) does two things: it adds the
dojo helper path to the view object -- which means you don't need that
last call to addHelperPath() above -- and enables dojo. This brings me
to my second point.

If you're *ever* using Dojo in your application, do this in your
bootstrap:

    Zend_Dojo::enableView($view);
    $view->dojo()->disable();

That way, you can selectively enable it in view scripts when you need
it. If you have any requirements that are necessary any time dojo is
enabled, set those in the bootstrap as well:

    $view->dojo()->setLocalPath($view->staticUrl('js/dojo/dojo.js'))
                 ->addStyleSheetModule('dijit.themes.tundra');

Then your layout script becomes really simple:

    <?= $this->dojo() ?>

If dojo is disabled, nothing will be emitted; if it's enabled, the
proper statements will appear.


> <style type="text/css">
> <!--
>     @import "/fourgon.net/public/js/dijit/themes/tundra/tundra.css";
> -->
> </style>
> <script type="text/javascript"
> src="/fourgon.net/public/js/dojo/dojo.js"></script>
> ...
> 
> 
> I don't understand why Dojo seem to be enabled by default?

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend Framework           | http://framework.zend.com/

Reply via email to