CJuiAccordion 封裝 jQuery UI Accordion,提供可摺疊內容面板,適用於 FAQ、側邊欄選單、分段式表單等場景。
<?php $this->widget('zii.widgets.jui.CJuiAccordion', array(
'panels' => array(
'面板一標題' => '面板一內容',
'面板二標題' => '面板二內容',
'面板三標題' => $this->renderPartial('_content1', null, true), // 支援局部視圖
),
'options' => array(
'collapsible' => true, // 允許全部摺疊
'active' => 1, // 預設展開第二個(0-based)
),
'htmlOptions' => array(
'style' => 'width:500px;',
),
)); ?>
panels:鍵值陣列,鍵=標題,值=內容(字串或渲染結果)options:透傳給 jQuery UI Accordion 的選項
collapsible:true 允許全部關閉,false 強制至少一開active:預設展開索引,false 全關event:觸發事件(click/mouseover)animate:動畫速度/緩動heightStyle:auto/fill/contenthtmlOptions:最外層容器 HTML 屬性'panels' => array(
'最新公告' => $this->renderPartial('_latest_news', array('limit'=>5), true),
'熱門文章' => $this->renderPartial('_popular_posts', true),
'用戶面板' => $this->renderPartial('_user_panel', array('user'=>Yii::app()->user), true),
),
引入自訂 jQuery UI Theme(ThemeRoller 產生),在配置檔設定:
'components' => array(
'clientScript' => array(
'scriptMap' => array(
'jquery-ui.css' => '/css/jui/custom/jquery-ui.css',
),
),
),