How to use yii 2.0 Bootstrap carousel?
I am using yii 2.0 framework and I would like to use Bootstrap carousel.
I know there is documentation, but can anyone explain to me what I need to do first? I have defined a new action in the controller and new view as in the documentation below. What should I edit?
SiteController
public function actionHello($message = "Hello"){
return $this->render('say', ['message' => $message]);
}
say.php view
<?php
use yii\helpers\Html;
?>
+3
source to share
1 answer
There is Yii 2.0
nothing to do in bootstrap widgets and it's pretty simple. I think you can do it like below:
$images=['<img src="/path/to/file1"/>','<img src="/path/to/file2"/>','<img src="/path/to/file3"/>'];
echo yii\bootstrap\Carousel::widget(['items'=>$images]);
Done.
You can transfer image files from your controller as shown below:
//getting all images
$images=['<img src="/path/to/file1"/>','<img src="/path/to/file2"/>','<img src="/path/to/file3"/>'];
return $this->render('say',['message'=>$message,'images'=>$images]);
Then in sight:
echo yii\bootstrap\Carousel::widget(['items'=>$images]);
You can read the official doc to make it clearer and more customizable with it.
+3
source to share