Hi Matthew,
That had already dawned on me as a good practice, when I started digging
into the helpers :). Thanks for confirming. Btw., as a long-long term Java
developer, starting with PHP and Zend Framework 1.6 has not only been easy
but also fun thanks to the excellent framework, docs and support by the
community. Kudos to y'all!
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-tp19387497p19392783.html
Sent from the Zend Framework mailing list archive at Nabble.com.