Tbcarousel Pass Array Of Images


Possibly a silly question. I have a bootstrap carousel widget defined as below. I want to pass an array of image paths to it. How do I do?

$this->widget('bootstrap.widgets.TbCarousel', array('items'=><img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />??));

My var_dump($images) array looks like this:

array(2) { [0]=> array(1) { ["id"]=> string(32) "images/carousel/thumbs/Koala.jpg" } [1]=> array(1) { ["id"]=> string(33) "images/carousel/thumbs/Tulips.jpg" } }



Have you seen the example here?

Items param for TbCarousel is array of image infos (for all images U need)

$items = [

// first image

0 => [

  'image' =&gt; this is required for forming src attr in img tag,

  'imageOptions' =&gt; other options for img

  'itemOptions' =&gt; htmlOptions


// second image


so in your case something like:

$items = [];

foreach($images as $image) {

$items[] = [

    'image' =&gt; &#036;image-&gt;id, 

…something else u want to pass to widget…



$this->widget(‘bootstrap.widgets.TbCarousel’, array(‘items’=>$items));

This worked! :) Thanks again.