简体   繁体   中英

sidebar menu doesnt show up Yii

I've been trying now for an hour to figure out how $this->menu works in Yii views. I found that you just put this in view file of controller and it should work, but for me it doesnt appear on web page.

$this->menu=array(
    array('label'=>'create', 'url'=>'/create/')
);

In your default layout used in controller for example:

public $layout='//layouts/column2'; 

You will find this in {appdir}/views/layouts/column2.php path. In this template you need to have this where you want to show the custom menu:

<?php
    $this->beginWidget('zii.widgets.CPortlet', array(
        'title'=>'',
        'hideOnEmpty'=>true,
    ));
    $this->widget('zii.widgets.CMenu', array(
        'items'=>$this->menu,
        'htmlOptions'=>array('class'=>'operations'),
    ));
    $this->endWidget();
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM