$this->widget(
'bootstrap.widgets.TbCarousel',
array(
'items' => array(
array(
'image' => bu('images/first-placeholder830x400.gif'),
'label' => 'First Thumbnail label',
'caption' => 'Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.'
),
array(
'image' => bu('images/second-placeholder830x400.gif'),
'label' => 'Second Thumbnail label',
'caption' => 'Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.'
),
array(
'image' => bu('images/third-placeholder830x400.gif'),
'label' => 'Third Thumbnail label',
'caption' => 'Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.'
),
),
)
);
My question, is how can I pass the values of image, label and caption stored from my database dynamically?
How are you creating your data provider? Is it not a CActiveDataProvider?
In any case, you probably don’t need to use a data provider. A simple array of active record objects should be perfectly fine. Data providers tend to be used when you have a bunch of records that you need to paginate and sort dynamically.
Aren’t you using active record? What you’ve done above would look more like this:
$users = User::model()->findAll();
If you don’t already use it, read through the active record section of the guide. It’s a powerful utility that will make your application much more maintainable.
In any case, if you’re using a CSqlDataProvider, I suspect you would need to use the following syntax in the function:
return array(
'image'=>'',
'label'=>CHtml::encode($record['file_name']), // <- $record is an array, not an object
'caption'=>CHtml::encode($record['name']),
);
You should definitely try to use active record if possible though.