View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

Zend_Dojo Arbitrary Dijit Support - Matthew Weier O'Phinney



1.0 - 14 January 2009: Initial Draft.

Zend_Dojo provides scaffolding for the Dojo environment, as well as view helpers and form support for a variety of Dijits. One key feature of Dojo is the ability to define your own dijits as well as to extend existing dijits. This goal of this proposal is to provide a view helper that can be used to generate markup and/or javascript for arbitrary dijits, as well as clearly define how to create view helpers to support your own dijits.

* [Widget creation tutorial|]
* [Zend_Dojo documentation|]

* This proposal *will* define a generic view helper for generating arbitrary Dijit markup and/or javascript
* This proposal *will* result in documentation on how to create view helpers to support custom Dijits.

* Zend_Dojo

Zend_Dojo view helpers already have a standard signature:
string helperName(string $id, string $content, array $params, array $attribs)
where $params defines Dijit-specific parameters, and $attribs defines HTML attributes to be included in markup. $content may be ignored depending on the dijit.

Additionally, layout container dijits allow you to return the helper instance in order to perform tasks such as capturing content or adding sub items:
Zend_Dojo_View_Helper_Dijit helperName()

The generic dijit view helper that will be created with this proposal will come in two flavors: dijit and container. These will follow the above signatures, and allow the developer to use arbitrary dijit types. The only difference in calling is that the $params member 'dojoType' *must* be specified; this will be used to ensure that the appropriate dojo.require statement is called and that the dijit type is associated with the markup and/or javascript generated. Additionally, an optional $params member, 'displayType', will be used to indicate if the dijit is rendered as a "block" (which will render a <div> by default) or as an "inline" element (rendered as a <span> by default); "block" will be the default. Finally, the tag to use for rendering may be specified using the "tagType" $params member.

* Milestone 1: Create proposal and submit for review
* Milestone 2: Create working prototypes, including unit tests, of generic dijit view helpers
* Milestone 3: Document generic dijit view helpers
* Milestone 4: Create documentation indicating how to create new dijit view helpers for custom dijits

* Zend_Dojo_View_Helper_CustomDijit
* Zend_Dojo_View_Helper_CustomDijitContainer

h4. Rendering a custom dijit
$this->customDijit('foo', $content, array(
'dojoType' => 'custom.Foo',
'displayType' => 'inline',

h4. Rendering a custom container dijit
$this->customDijitContainer()->captureStart('foo', array('dojoType' => 'custom.Foo'));
?><p>This is some content to be captured.</p><?php
echo $this->customDijitContainer()->captureEnd('foo'); ?>

TBD; will mimic existing dijit support