how to create db based accordion
how to create db based accordion
After getting your data, you can use [size=“2”]CHtml’s listData()[/size][size=“2”] to format the data, and then use the [/size]CJuiAccordion widget to generate an accordion. If for example you have model “Group” and want to display all groups in an accordion list, you could do the following
<?php
$groups = Group::model()->findAll(); // get all groups
$groupsList = CHtml::listData($groups, 'name', 'description'); // format group data as key and value for cjuiaccordion
$this->widget('zii.widgets.jui.CJuiAccordion', array(
'panels'=>$groupsList, // accepts array of keys and values to generate accordion: key is panel heading, value is panel content that opens on heading click
'options'=>array(
'collapsible'=>true,
'active'=>1,
),
'htmlOptions'=>array(
'style'=>'width:500px;'
),
));
?>