+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: Dojo in Zend_Layout

  1. #1
    Risratorn is offline Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Default Dojo in Zend_Layout

    Does anyone have an idea why this doesn't work.
    I'm trying to render a Dojo borderContainer in my Zend_Layout that is used across my whole CMS backend. The bizare thing is that when i move the whole code to the view it works like a charm, but when i try to use the Dojo helpers in the Zend_layout nothing happens.

    For one or another reason the classes and dojotype attributes don't get rendered on the generated divs, they are just outputted without the right attributes for dojo to transform them into the desired layout.

    [PHP]<?php

    $this->headLink()->appendStylesheet($this->autover('/admin/css/style.css'));
    $this->headTitle()->setSeparator(' :: ');
    $this->headTitle()->append('Skyrocket Admin');

    echo $this->doctype() ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <?= $this->headTitle() ?>
    <?= $this->headLink() ?>
    <?= $this->headStyle() ?>
    <?= $this->headScript() ?>

    <?
    $this->dojo()->setLocalPath('/admin/scripts/dojo/dojo.js')
    ->addStyleSheetModule('dijit.themes.tundra');
    echo $this->dojo();
    ?>
    </head>
    <body class="tundra">

    <?
    /**
    * The page layout is a borderContainer, the views
    * get rendered in the Center pane
    */
    $this->borderContainer()->captureStart('masterLayout',
    array('design' => 'headline'),
    array('style' => 'width: 100%; height: 100%'));

    /**
    * The Top panel with the module list
    */
    $this->contentPane()->captureStart('topPane',
    array('region' => 'left', 'splitter' => true),
    array('style' => 'width: 200px'));
    // {{{
    ?>
    <ul id="navigation" style="margin: 0">
    <li><a href="/admin/pages">Pages</a></li>
    <li><a href="/admin/auth/logout">Logout</a></li>
    </ul>
    <?
    // }}}
    echo $this->contentPane()->captureEnd('topPane');

    /**
    * The Center panel with the module list
    */
    $this->contentPane()->captureStart('contentPane',
    array('region' => 'center'),
    array());
    // {{{
    if(isset($this->flashMessages) && sizeof($this->flashMessages) > 0): foreach($this->flashMessages as $flashMessage):
    echo "<p>$flashMessage</p><hr />";
    endforeach; endif;

    echo $this->layout()->content;
    // }}}
    echo $this->contentPane()->captureEnd('contentPane');

    echo $this->borderContainer()->captureEnd('masterLayout');
    ?>

    </body>
    </html>
    [/PHP]

  2. #2
    Eugen is offline Senior Member
    Join Date
    Sep 2008
    Location
    Croatia
    Posts
    400

    Default

    are the dijit.layout.ContentPane and dijit.layout.BorderContainer included in html?

  3. #3
    Risratorn is offline Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Default

    Quote Originally Posted by Eugen View Post
    are the dijit.layout.ContentPane and dijit.layout.BorderContainer included in html?
    Yes, dojo loads fine. the problem is the attributes don't get added to the elements the echo statements produce. Tonight maybe digg a little deeper into the dojo helpers, unless someone else knows what is going on.

  4. #4
    kdeberna is offline Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Default

    I am experiencing a very similar problem using Dojo, Zend_Dojo_Form, and a Dijit Dialog (my form is echoed out from the Controller). The Dojo-ized form (a TabContainer) renders correctly from a view script, but when placed in a Dijit Dialog all the elements are rendered but none of the interaction or functionality. I have also successfully created a TabContainer in the Dijit Dialog, but that was from the .js file and was not utilizing Zend_Dojo_Form.

    My confusion is why the same form renders correctly in the view script, but not in the Dijit Dialog.

    I've attached a screenshot in which you can see 1) the form rendered correctly behind the Dialog, and 2) the exact same form rendered incorrectly in the Dialog.
    Attached Images

  5. #5
    Risratorn is offline Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Default

    Allright, i found the solution.

    The problem lies in the fact that the helpers that create the dijits insert JS code in the <head> of your page using <?= $this->dojo() ?>. This causes a problem because everything Dojo or Dijit related should be executed before this line since this outputs the required code to generate dijits.

    When the <?= $this->dojo() ?> line is outputted you CANNOT add more dijits to your layout, be sure to create them before you output <?= $this->dojo() ?>

    When i moved all my dijit creation related code to the top of my Layout and later echoed the output at the right location the dijits work like a charm!
    Last edited by Risratorn; 02-11-2009 at 07:42 PM.

  6. #6
    kdeberna is offline Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Default

    Risratorn, can you post some of code you are referring to? The problem I am having is that without <?= $this->dojo() ?> I can't add dijits (since dojo.js hasn't been included) but when I add them after <?= $this->dojo() ?> they aren't rendered.

    This is the head section of my layout file:
    [HTML]<head>
    <?php echo $this->headMeta()."\n"; ?>
    <?php echo $this->headTitle()."\n"; ?>
    <?php echo $this->headLink()."\n"; ?>
    <?php
    if($this->dojo()->isEnabled()){
    $this->dojo()->setLocalPath('/scripts/dojo/dojo.js')
    ->addStyleSheetModule('dijit.themes.tundra');
    echo $this->dojo();
    }
    ?>
    <?php echo $this->headScript()."\n"; ?>
    </head>[/HTML]

    This is a portion of my index.phtml script:
    [PHP]<?php $this->dojo()->enable()
    ->requireModule('dijit.Dialog')
    ->requireModule('dijit.form.Button')
    ->requireModule('dijit.layout.TabContainer'); ?>
    <?php $this->headScript()->appendFile('addPiece.js'); ?>

    <div id="ButtonHolder"><a href="#" id="AddPiece">Add piece</a></div><br /><br />

    <p>Filter the results to narrow down to a specific piece.</p>[/PHP]

    And this is the included js file, addPiece.js:
    Code:
    dojo.addOnLoad( function() {
    	new dijit.form.Button({label: "Add Piece", id: "Add"}, dojo.byId('ButtonHolder'));
    	dojo.connect(dojo.byId("Add"), "onclick", doAdd);
    	loadWindow();
    });
    
    function loadWindow() {
    	var addPieceDialog = new dijit.Dialog({
    		title: "Add New Piece",
    		href: "/xxxxx/pieces/popup/",
    		draggable: false,
    		autofocus: false,
    		preload: true,
    		parseOnLoad: true,
    		style: "width: 600px; height: 450px"
    	});
    	addPieceDialog.startup();
    	addPieceDialog.hide();
    	doAdd.piece = addPieceDialog;
    }
    
    function doAdd(event) {
    	dojo.stopEvent(event);
    	doAdd.piece.show();
    }
    The js get's the form from a controller action called popupAction() and is as follows:
    [PHP]public function popupAction() {
    $this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender();
    echo new My_TabbedForm;
    }[/PHP]

    And finally, the actual form is coming from this library file (truncated):
    [PHP]<?php

    class My_TabbedForm extends Zend_Dojo_Form
    {

    public function init() {

    $this->setDecorators(array(
    'FormElements',
    array('TabContainer', array(
    'id' => 'tabContainer',
    'style' => 'width: 525px; height: 300px;',
    'dijitParams' => array(
    'tabPosition' => 'top'
    )
    )),
    'DijitForm'
    ));

    $subForm1 = new Zend_Dojo_Form_SubForm();
    $subForm1->setAttribs(array(
    'name' => 'attributesTab',
    'legend' => 'Attributes',
    'dijitParams' => array(
    'title' => 'Attributes'
    )
    ));

    $subForm1->addElement('TextBox', 'title', array(
    'label' => 'Title:'
    ));

    $subForm1->addElement('Editor', 'description', array(
    'label' => 'Description:'
    ));

    $subForm2 = new Zend_Dojo_Form_SubForm();
    $subForm2->setAttribs(array(
    'name' => 'imagesTab',
    'legend' => 'Images',
    'dijitParams' => array(
    'title' => 'Images'
    )
    ));

    $subForm2->addElement('Textarea', 'holder', array(
    'label' => 'Holder:'
    ));

    $this->addSubForm($subForm1, 'attributesTab')
    ->addSubForm($subForm2, 'imagesTab');
    }
    } ?>[/PHP]

    The results should be a dijit dialog (which renders and functions correctly) populated with a two tab TabContainer. The TabContainer is not rendered correctly though. All the form elements appear, but are not styled or dojo enabled.

    Any thoughts? Thanks.

  7. #7
    mapes911 is offline Junior Member
    Join Date
    Aug 2008
    Location
    Vancouver, B.C., Canada
    Posts
    6

    Default

    Hey guys,

    I too would love to see code on how you solved this problem. Looks like it could help me with my problem.

    Loading a dojo form in a div using xhrGet

    Thanks!!

  8. #8
    Risratorn is offline Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Default

    Well i posted on my blog about it, maybe this could help you guys out?

    Dojo Dijits in Zend_Layout | Skyrocket.be

  9. #9
    Venimus is offline Junior Member
    Join Date
    Jun 2009
    Posts
    6

    Default

    i had the same problem but fixed it by setting decorators for each subform

    [PHP]
    $subForm1->setDecorators(array(
    'DijitForm',
    'FormElements',
    'ContentPane',
    ));
    [/PHP]
    Last edited by Venimus; 06-24-2009 at 01:34 PM.

  10. #10
    mikle19 is offline Junior Member
    Join Date
    Jan 2010
    Posts
    1

    Default

    I had a problem that dijit BorderContainer wasnt working. Was playing around.
    I had to put this string
    Code:
    <link id="themeStyles" rel="stylesheet" href="/js/dojo/dijit/themes/tundra/tundra.css">
    And this only wasnt working
    Code:
    @import "/js/dojo/dijit/themes/tundra/tundra.css";

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Zend_Layout issues
    By sosh in forum General Q&A on Zend Framework
    Replies: 6
    Last Post: 02-10-2009, 09:59 PM
  2. Zend_Layout
    By morthomtech in forum Model-View-Controller (MVC)
    Replies: 0
    Last Post: 12-29-2008, 03:30 PM
  3. How to use Zend_Layout ?
    By MiK in forum Model-View-Controller (MVC)
    Replies: 5
    Last Post: 11-09-2008, 05:44 PM
  4. zend_layout
    By rufinus in forum Model-View-Controller (MVC)
    Replies: 3
    Last Post: 05-28-2008, 10:30 PM
  5. Zend_Layout with Zend_View_Smarty
    By StevenHill in forum General Q&A on Zend Framework
    Replies: 2
    Last Post: 02-12-2008, 11:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts