renderPortlets
16. Januar 2012
//views/layouts.main.php
<div class="span-6 last">
<div id="sidebar">
<?php $this->renderPortlets('right'); ?>
</div>
</div>//components/Controller.php class Controller extends CController { public $portlets = array(); public function addPortlet($position, $portlet) { $this->portlets[$position][] = $portlet; } public function renderPortlets($position) { if (isset($this->portlets[$position])) { foreach ($this->portlets[$position] as $portlet) { $this->beginWidget('zii.widgets.CPortlet', array( 'title' => $portlet['title'], )); $this->widget($portlet['class'], $portlet['params']); $this->endWidget(); } } } }
//views/article/view.php $this->addPortlet('right', array( 'class' => 'zii.widgets.CMenu', 'title' => 'Operations', 'params' => array( //Configuration CMenu 'items' => array( array('label' => 'List Article', 'url' => array('index')), array('label' => 'Create Article', 'url' => array('create')), array('label' => 'Update Article', 'url' => array('update', 'id' => $model->id)), array('label' => 'Delete Article', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), ), 'htmlOptions' => array('class' => 'operations') ) )); $this->addPortlet('right', array( 'class' => 'ArticleInfoWidget', 'title' => 'ArticleInfo', 'params' => array( 'article' => $model ) ));

Letzte Kommentare