Yii Framework Forum: How To Create Db Based Accordion - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Create Db Based Accordion how to create db based accordion Rate Topic: ***** 1 Votes

#1 User is offline   Rathilesh 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 16-May 13

Posted 17 May 2013 - 06:14 AM

how to create db based accordion
0

#2 User is offline   beninblack 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 27-November 10
  • Location:BC Canada

Posted 17 May 2013 - 09:31 PM

View PostRathilesh, on 17 May 2013 - 06:14 AM, said:

how to create db based accordion


After getting your data, you can use CHtml's listData() to format the data, and then use the 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;'
    ),
));

?>

Ben
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users