Home > Yii > renderPortlets

renderPortlets

//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
  )
));

Verwandte Artikel:

  1. yiiframework – Guidelines for good schema design
  2. CButtonColumn erweitern
  3. Parameterized Named Scopes
  4. Gegen DB authentifizieren
  5. CGridColumn
  6. Ein Modul als Admin Backend
  7. Ein Anrede-Behavior
  8. CGridView
  9. Anonyme Funktionen
  10. Wie ich Datenbank-Tabellen und -Felder benenne
  11. Models aus Modulen verwenden
  12. yiic shell
  13. Widgets
  14. Yii Module
  15. Yii Message Translation
Author: Categories: Yii Tags: ,
  1. Bisher keine Kommentare
  1. Bisher keine Trackbacks