utopian
(Priya Rajan)
1
Hi,
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" } }
Thanks.
Cheers
Keith
(Kburton)
2
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' => this is required for forming src attr in img tag,
'imageOptions' => other options for img
'itemOptions' => htmlOptions
]
// second image
…
]
so in your case something like:
$items = [];
foreach($images as $image) {
$items[] = [
'image' => $image->id,
…something else u want to pass to widget…
]
}
$this->widget(‘bootstrap.widgets.TbCarousel’, array(‘items’=>$items));
utopian
(Priya Rajan)
4
This worked!
Thanks again.