blog.morf.cz

Tag: Zend Framework

Zend Framework Custom Dojo (Dijit) Helpers

by morf on Dec.26, 2009, under Blog

Implementing custom Dojo or Dijit into the Zend Framework View Helper is pretty simple. Lately i need this feature for Menu and MenuItem Dijits. I will provide you an example how to do it yourself for another Dijits. This example should work with other Dijits as well (i tried Dialog, DropDownButton, Menu, MenuBar, MenuItem, TitlePane, ToolBar, Tooltip Dialog, and Tree so far).

Ok let’s show the code. You have to create custom Dijit Zend_View_Helper by extending Zend_Dojo_View_Helper_DijitContainer class. Don’t forget to alter: DocBlock, $_dijit, $_module, and direct function (eg. menu() or menuItem() ) and function DocBlock.

Implementace vlastních Dojo nebo Dijit pomocí Zend Framework View Helper je pěkně jednoduché. Nedávo jsem potřeboval tuto vlastnost pro Dijit Menu a MenuItem. Poskytnu vám příklad jak to můžete udělat sami pro jiné Dijit. Tento příklad by měl fungovat pro ostatní Dijity bez problémů (zkoušel jsem Dialog, DropDownButton, Menu, MenuBar, MenuItem, TitlePane, ToolBar, Tooltip Dialog, a Tree zatím).

Ok následuje ukázka kódu. Budete muset vytvořit vlastní Zend_View_Helper rozšířením (extend) třídy Zend_Dojo_View_Helper_DijitContainer. Nezapomeňte změnit: DocBlock, $_dijit, $_module, a funkci pro přímé voláním (např. menu() nebo menuItem()) a DocBlock funkce.


Sorry Code Highlight is broken … :-(


Omlouvám se ale zvýraznění kódu je mimo provoz … :-(

/**
 * Dijit Menu Implementation
 * @author morf
 * @version
 */

/**
 * Menu helper
 *
 * @uses viewHelper Zend_View_Helper
 */
class Zend_View_Helper_Menu extends Zend_Dojo_View_Helper_DijitContainer
{
 /**
 * Dijit being used
 * @var string
 */
 protected $_dijit  = 'dijit.Menu';

 /**
 * Dojo module to use
 * @var string
 */
 protected $_module = 'dijit.Menu';

 /**
 * dijit.Menu
 *
 * @param  string $id
 * @param  string $content
 * @param  array $params  Parameters to use for dijit creation
 * @param  array $attribs HTML attributes
 * @return string
 */
 public function menu($id = null, $content = '', array $params = array(), array $attribs = array()) {
 if (0 === func_num_args()) {
 return $this;
 }

 return $this->_createLayoutContainer($id, $content, $params, $attribs);
 }
}
/**
 * Dijit MenuItem Implementation
 * @author morf
 * @version
 */

/**
 * MenuItem helper
 *
 * @uses viewHelper Zend_View_Helper
 */
class Zend_View_Helper_MenuItem extends Zend_Dojo_View_Helper_DijitContainer
{
 /**
 * Dijit being used
 * @var string
 */
 protected $_dijit  = 'dijit.MenuItem';

 /**
 * Dojo module to use
 * @var string
 */
 protected $_module = 'dijit.MenuItem';

 /**
 * dijit.MenuItem
 *
 * @param  string $id
 * @param  string $content
 * @param  array $params  Parameters to use for dijit creation
 * @param  array $attribs HTML attributes
 * @return string
 */
 public function menuItem($id = null, $content = '', array $params = array(), array $attribs = array()) {
 if (0 === func_num_args()) {
 return $this;
 }

 return $this->_createLayoutContainer($id, $content, $params, $attribs);
 }
}
/**
 * Usecase:
 */
 $this->menu()->captureStart(
 'hosting-nav-menu',
 array(),
 array(
 'style' => 'width: 100%',
 )
 );

 echo $this->menuItem(
 'hosting-nav-menu-programm',
 'Programms',
 array(),
 array()
 );

 echo $this->menuItem(
 'hosting-nav-menu-service',
 'Services',
 array(),
 array()
 );

 echo $this->menuItem(
 'hosting-nav-menu-ad',
 'Ads',
 array(),
 array()
 );

 echo $this->menu()->captureEnd('hosting-nav-menu');

Now you can download working example application here.

VN:F [1.8.7_1070]
Rating: 7.0/10 (2 votes cast)
VN:F [1.8.7_1070]
Rating: 0 (from 0 votes)
2 Comments :, , , , more...

Zend Framework 1.8.4

by morf on Jun.28, 2009, under Blog

Before a while ZF 1.8 came out with a new feature called Zend Tool. I was excited, and tried to work with it, but i discovered few errors in module based application generating capabilities, so i submited two issues in bug tracking system ZF-6853, and ZF-6755. And now in new version 1.8.4 issues are fixed. Good work ZF Team.

Před nedávnem přišel ZF 1.8 s novou featurou nazvanou Zend Tool. Byl jsem nadšený a zkoušel s ní pracovat, ale objevil jsem několik chyb v možnostech generování modulární aplikací, takže jsem odeslal dvě issue do bug tracking systému ZF-6853, a ZF-6755. A nyní ve v nové verzi 1.8.4 jsou issue opraveny. Dobrá práce ZF Team.

VN:F [1.8.7_1070]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.7_1070]
Rating: 0 (from 0 votes)
Leave a Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!