No issues anymore. It works like a charm. To document, here is how I do
things now and hope this is the best possible practice:

1) Relevant parts of my bootstrap file:

    // Set up the default layout
    $layout = Zend_Layout::startMvc();
    $layout->setLayoutPath(GGV_PATH_ROOT . '/application/views/layouts');
                      
    // Set up Dojo
    $view = Zend_Layout::getMvcInstance()->getView();
    Zend_Dojo::enableView($view); 
    $view->dojo()->setLocalPath($config->www->baseurl .
'/js/dojo/dojo/dojo.js')
                 ->addStyleSheetModule('dijit.themes.tundra')
                 ->disable();     

    // Set up the front controller and dispatch
    $front = Zend_Controller_Front::getInstance();
    $front->registerPlugin(new LoggerPlugin());
    $front->throwExceptions(false);
    $front->setControllerDirectory(GGV_PATH_ROOT .
'/application/controllers');
    $front->setBaseUrl($config->www->baseurl);
    $front->dispatch();

2) My layout script:

<?= $this->doctype('XHTML1_STRICT') ?>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
    <?= $this->headTitle($this->page_title) ?> 
    <?php $this->headMeta()->appendHttpEquiv('Content-Type', 'text/html;
charset=UTF-8'); echo $this->headMeta(); ?> 
    <?php
$this->headLink()->appendStylesheet(Zend_Controller_Front::getInstance()->getBaseUrl()
. '/css/common.css'); echo $this->headLink(); ?> 
    <?= $this->headStyle() ?>
    <?= $this->dojo() ?>  
    <?= $this->headScript() ?> 
</head>
<body class="tundra">
    <?= $this->render('partials/html_header.phtml') ?>
    <?= $this->layout()->content ?>
    <?= $this->inlineScript() ?>
    <?= $this->render('partials/html_footer.phtml') ?>
</body>
</html>

3) My action view script:

<?php

// Enable Dojo
$this->dojo()->enable();

?>
<div>
<?= $this->dateTextBox('foo', '2008-07-11', array('required' => true)) ?>

</div>

4) My action controller:

    public function loginAction()
    {
        $this->render();
    }

Thanks!!





Matthew Weier O'Phinney-3 wrote:
> 
> -- Peter Wansch <[EMAIL PROTECTED]> wrote
> (on Tuesday, 09 September 2008, 12:46 AM -0700):
>> 
>> I am trying to find out what the best practice for using Dojo widgets in
>> a
>> Zend MVC application is. 
>> The following works:
>> 
>> 1) In my view script xxxx.phtml I have the following:
>> <?php
>> 
>> // Render common HTML header
>> echo $this->render('partials/html_header.phtml');
>> 
>> ?>
>> <div>
>> <?= $this->dateTextBox('foo', '2008-07-11', array('required' => true)) ?>
>> <?= $this->dojo() ?>
>> <?= $this->render('partials/html_footer.phtml'); ?>
>> 
>> 2) My partial html_header.phtml looks like this:
> 
> Stop. First, you need to refactor to use Zend_Layout; including a header
> and footer in each page is a really, really bad idea for long term
> maintainability. Additionally, The dojo() view helper is designed to
> work *with* a layout strategy -- define your various modules, etc,
> directly in your view scripts, and then simply echo the dojo() view
> helper in your layout -- and all will just work.
> 
> Give Zend_Layout a try, and then let us know if you're still having
> issues.
> 
>> <?= $this->doctype('XHTML1_STRICT') ?>
>> <html xmlns="http://www.w3.org/1999/xhtml";>
>> <head>
>>     <?= $this->headTitle($this->page_title) ?> 
>>     <?php $this->headMeta()->appendHttpEquiv('Content-Type', 'text/html;
>> charset=UTF-8'); echo $this->headMeta(); ?> 
>>     <?php
>> $this->headLink()->appendStylesheet(Zend_Controller_Front::getInstance()->getBaseUrl()
>> . '/css/common.css'); echo $this->headLink(); ?> 
>>     <?= $this->headStyle() ?>
>>     <?= $this->dojo() ?>  
>>     <?= $this->headScript() ?> 
>> </head>
>> <body class="tundra">
>> 
>> 3) In my controller base class in the init method I do this:
>> 
>>             Zend_Dojo::enableView($this->view); 
>>            
>> $this->view->dojo()->setLocalPath(Zend_Controller_Front::getInstance()->getBaseUrl()
>> . '/js/dojo/dojo/dojo.js')
>>                        ->addStyleSheetModule('dijit.themes.tundra')
>>                        ->disable();
>> 4) When needed in the specific controller action method, I enable dojo:
>>     public function xxxxAction()
>>     {
>>         // Enable Dojo
>>         $this->view->dojo()->enable();        
>> 
>> This works, but the this->dojo in my header is pointless. It only
>> includes
>> the main dojo.js. If I don't print this->dojo() after I declare my Dojo
>> widget in the view script, the dijit code :
>> 
>> <script type="text/javascript">
>> //<![CDATA[
>> dojo.require("dijit.form.DateTextBox");
>>     dojo.require("dojo.parser");
>> dojo.addOnLoad(function() {
>>     dojo.forEach(zendDijits, function(info) {
>>         var n = dojo.byId(info.id);
>>         if (null != n) {
>>             dojo.attr(n, dojo.mixin({ id: info.id }, info.params));
>>         }
>>     })
>>     dojo.parser.parse();
>> });
>> var zendDijits =
>> [{"id":"foo","params":{"required":"true","dojoType":"dijit.form.DateTextBox"}}];
>> //]]>
>> 
>> does not get generated. Somehow this does not look right. All the
>> examples I
>> have seen just have the call to dojo() in their respective layout
>> scripts.
>> Is that only when I use ZendLayout that the layout content gets parsed
>> first?
>> -- 
>> View this message in context:
>> http://www.nabble.com/Where-to-put-tp19387497p19387497.html
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>> 
> 
> -- 
> Matthew Weier O'Phinney
> Software Architect       | [EMAIL PROTECTED]
> Zend Framework           | http://framework.zend.com/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Where-to-put-tp19387497p19401186.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to