CJuiAccordion and db objects

does anyone used the CJuiAccordion widget?

for the panels you cannot parse an object wich you get back from your model. and there is no way to build a foreach loop in the widget code?

so how to implement this widget the right and easiest way?

i tried CHtml::listData(Category::model()->findAll(), ‘IdCategory’, ‘Category’) but in need more content for the panel then only the Category field…

Please, could you bring an example of what you are trying to do?

Thanks,

i try to implement the CJuiAccordion. So i wrote a query Daytrip::model()->findAll(); this will give me object from Daytrip wich contains an id, title, city, distance, etc.

but i was expecting that you can parse the result of the query to the view and use it directly for the CJuiAccordion widget.

below you’ll find my work-around… i made my own <div> container with the exact same name as the widget will create. because i put the javascript code below my own <div> container the widget will make the first <div> the accordion div.

so my question is, how to use objects to fill the panel title and panel content.

work-around:




<div id="accordion" class="ui-accordion ui-widget ui-helper-reset" role="tablist">

<?php foreach($daytrips as $daytrip): ?>

    <h3><a href="#"><?php echo $daytrip->Daytrip; ?></a></h3>

    <div>

        <p>Stad: <?php echo $daytrip->rCity->City; ?></p>

        <p>Afstand: <?php echo $daytrip->Distance; ?></p>

<?php if($daytrip->YouTube != ''): ?>

        <object width="320" height="265">

            <param name="movie" value="<?php echo str_replace('watch?v=', 'v/', $daytrip->YouTube); ?>&hl=nl_NL&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999"></param>

            <param name="allowFullScreen" value="true"></param>

            <param name="allowscriptaccess" value="always"></param>

            <embed src="<?php echo str_replace('watch?v=', 'v/', $daytrip->YouTube); ?>&hl=nl_NL&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="320" height="265"></embed>

        </object>

<?php endif; ?>

    </div>

<?php endforeach; ?>

</div>


<?php

$this->widget('zii.widgets.jui.CJuiAccordion', array(

    'id' => 'accordion',

    // additional javascript options for the accordion plugin

    'options'=>array(

        'autoHeight' => false,

        'collapsible' => true

    ),

));

?>



Nor really an answer to your question, but thanks! This helped me create a simpler CJuiSortable solution, no need to put everything in an array to feed the widget.




$panels = Publikation::model()->findAll('level=:level', array(':level' => 1));


foreach($panels as $panel) {

  foreach($panel->getChildNodes() as $childpanel) {

    if(!Yii::app()->user->isguest) {

      $update .= "<nobr>";

      $update .= CHtml::link(CHtml::image('/Piw/img/update.png', 'B', array('border' => 0, 'title' => 'Bearbeiten')), array('Publikation/update', 'id' => $childpanel->id));

      $update .= CHtml::link(CHtml::image('/Piw/img/plus.png', '+', array('border' => 0, 'title' => 'Neuer Artikel')), array('Publikation/create', 'publikationParent' => $childpanel->id));

      $update .= CHtml::link(CHtml::image('/Piw/img/up.gif', 'Hoch', array('border' => 0, 'title' => 'Nach Oben')), array('Publikation/moveLeft', 'id' => $childpanel->id));

      $update .= CHtml::link(CHtml::image('/Piw/img/down.gif', 'Runter', array('border' => 0, 'title' => 'Nach Unten')), array('Publikation/moveRight', 'id' => $childpanel->id));

//      $update .= CHtml::link(CHtml::image('/Piw/img/left.jpg', '<<', array('border' => 0, 'title' => 'Nach Links')), array('Publikation/moveUp', 'id' => $childpanel->id));

// $update .= CHtml::link(CHtml::image('/Piw/img/right.jpg', '>>', array('border' => 0, 'title' => 'Nach Rechts')), array('Publikation/moveDown', 'id' => $childpanel->id));

      $update .= "</nobr>";

    }

    $data .= sprintf("<li>%s %s</li>", CHtml::link($childpanel->title, array('Publikation/list', 'id' => $childpanel->id), ($childpanel->id == $_GET['id']) ? array('style' => 'font-weight:bold;'): array()), $update);

    $update = "";

  }

    if(!Yii::app()->user->isguest) {

  $data .= "<br />" . CHtml::link("[Neuer Unterpunkt]", array('create', 'publikationParent' => $panel->id));

    }

  $Panels[$panel->title] = $data;

  $data = "";

}


$this->widget('zii.widgets.jui.CJuiAccordion', array(

  'panels'=>$Panels

  ,

  'options'=>array(

    'animated'=>'bounceslide',

    'collapsible'=>'true',

    'navigation'=>'true',

  ),

));



?? :slight_smile:


$publication_panels=array();

if (count($model->publicationIssueSections)<=0){

	echo 'There are currently no sections for Issue '.$model->publication_issue_id;	

}else{


	foreach($model->publicationIssueSections as $section){

		$section_count=$section->PublicationBookCount;

		$publication_panels[$section->section_name.' ('.$section_count.')']=$this->renderPartial('_overviewsection',array('section'=>$section),true);

	}

}


$publication_panels['NEWPANELTITLE']='this is just another panel with inline <b>html</b>';


$this->widget('zii.widgets.jui.CJuiAccordion', array(

    'panels'=>$publication_panels,

    // additional javascript options for the accordion plugin

    'options'=>array(

		'active'=>false,

		'collapsible'=>true,

		'clearStyle'=>true

    ),

));

3534

demo.png