ScrollPicView.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Author: lf
  4. * Blog: https://blog.feehi.com
  5. * Email: job@feehi.com
  6. * Created at: 2016-06-19 14:46
  7. */
  8. namespace frontend\widgets;
  9. class ScrollPicView extends \yii\base\Widget
  10. {
  11. public $banners;
  12. public $template = "<ul class='slick centered-btns centered-btns1' style='max-width: 1309px;'>{lis}</ul>
  13. <a href='' class=\"centered-btns_nav centered-btns1_nav prev\">Previous</a>
  14. <a href='' class=\"centered-btns_nav centered-btns1_nav next\">Next</a>";
  15. public $liTemplate = "<li id=\"centered-btns1_s0\" class=\"\" style=\"display: list-item; float: none; position: absolute; opacity: 0; z-index: 1; transition: opacity 700ms ease-in-out;\">
  16. <a target='{target}' href=\"{link_url}\"><img class=\"img_855x300\" src=\"{img_url}\" alt=\"\"><span></span></a>
  17. </li>";
  18. /**
  19. * @inheritdoc
  20. */
  21. public function run()
  22. {
  23. parent::run();
  24. $lis = '';
  25. foreach ($this->banners as $banner) {
  26. $lis .= str_replace(['{link_url}', '{img_url}', '{target}'], [$banner['link'], $banner['img'], $banner['target']], $this->liTemplate);
  27. }
  28. return str_replace('{lis}', $lis, $this->template);
  29. }
  30. }