Difference between #13 and #14 of
Create Bootstrap5 based Image carousel with thumbnails

Revision #14 has been created by pravi on Dec 4, 2023, 10:54:05 AM with the memo:

formatting
« previous (#13) next (#15) »

Changes

Title unchanged

Create Bootstrap5 based Image carousel with thumbnails

Category unchanged

Tutorials

Yii version unchanged

2.0

Tags unchanged

carousel,bootstrap5 carousel

Content changed

[...]
```
Here is a Corousel widget that is an extension of yii\bootstrap5\Carousel, to show image thumbnails as indicators for the carousel.

Here is the widget code.
    <?php     namespace app\widgets;     use Yii;     use yii\bootstrap5\Html;     class Carousel extends \yii\bootstrap5\Carousel     {      public $thumbnails = [];     public function init()     {      parent::init();      Html::addCssClass($this->options, ['data-bs-ride' => 'carousel']);     if ($this->crossfade) {      Html::addCssClass($this->options, ['animation' => 'carousel-fade']); }
 
}
 
        }
 

 
  public function renderIndicators(): string      {     if ($this->showIndicators === false){     return '';     }     $indicators = [];      for ($i = 0, $count = count($this->items); $i < $count; $i++){     $options = [     'data' => [      'bs-target' => '#' . $this->options['id'],     'bs-slide-to' => $i     ],      'type' => 'button',                     'thumb' => $this->thumbnails[$i]['thumb']     ];     if ($i === 0){      Html::addCssClass($options, ['activate' => 'active']);     $options['aria']['current'] = 'true';     }
 

 
                
$indicators[] = Html::tag('li',Html::img($options['thumb']), $options); }
 
    }
 
    
return Html::tag('ol', implode("\n", $indicators), ['class' => ['carousel-indicators']]);      } }
2 0
1 follower
Viewed: 78 675 times
Version: 2.0
Category: Tutorials
Written by: pravi
Last updated by: pravi
Created on: Dec 4, 2023
Last updated: 11 months ago
Update Article

Revisions

View all history