From 2cf056df2f6b2b3b5511a061be9218498d965301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20B=C3=A9jean?= <nicolas@bejean.eu> Date: Sat, 9 May 2020 18:31:30 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9veloppement=20du=20widget?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Block/Widget/CategoryWidgetNew.php | 160 ++++++++++++------ etc/widget.xml | 99 +++++++---- view/frontend/layout/default.xml | 5 +- .../widget/categorywidget/default.phtml | 95 +++++++---- 4 files changed, 242 insertions(+), 117 deletions(-) diff --git a/Block/Widget/CategoryWidgetNew.php b/Block/Widget/CategoryWidgetNew.php index 725d3a5..b1f09e4 100755 --- a/Block/Widget/CategoryWidgetNew.php +++ b/Block/Widget/CategoryWidgetNew.php @@ -18,15 +18,15 @@ use \NicolasBejean\CategoryWidget\Model\CategoryWidgetRepository; use \NicolasBejean\CategoryWidget\Model\CategoryWidgetFactory; use \NicolasBejean\CategoryWidget\Model\Template\FilterProvider; -use \NicolasBejean\MediaManager\Model\ImageRepository; -use \NicolasBejean\MediaManager\Model\Image as ImageModel; +use \Magento\Catalog\Model\CategoryRepository; +use \Magento\Catalog\Model\Category as CategoryModel; use \Exception; use \Magento\Framework\Exception\LocalizedException; use \Magento\Framework\Exception\NoSuchEntityException; /** - * Class CategoryWidgetNEw for Widget + * Class CategoryWidgetNew for Widget * * @category PHP * @package NicolasBejean\CategoryWidget\Block\Widget @@ -47,7 +47,7 @@ class CategoryWidgetNew extends Template implements BlockInterface protected $filterProvider; /** - * Category Widget factory + * Category Widget Factory * * @var CategoryWidgetFactory */ @@ -95,9 +95,9 @@ class CategoryWidgetNew extends Template implements BlockInterface protected $imageOptimizer; /** - * @var ImageRepository + * @var CategoryRepository */ - private $imageRepository; + private $categoryRepository; /** * @var CategoryWidgetRepository @@ -109,7 +109,7 @@ class CategoryWidgetNew extends Template implements BlockInterface * @param FilterProvider $filterProvider * @param CategoryWidgetFactory $categoryWidgetFactory * @param CategoryWidgetRepository $categoryWidgetRepository - * @param ImageRepository $imageRepository + * @param CategoryRepository $categoryRepository * @param ImageOptimizer $imageOptimizer * @param ImageAdapterFactory $imageAdapterFactory * @param array $data @@ -119,7 +119,7 @@ class CategoryWidgetNew extends Template implements BlockInterface FilterProvider $filterProvider, CategoryWidgetFactory $categoryWidgetFactory, CategoryWidgetRepository $categoryWidgetRepository, - ImageRepository $imageRepository, + CategoryRepository $categoryRepository, ImageOptimizer $imageOptimizer, ImageAdapterFactory $imageAdapterFactory, array $data = [] @@ -130,50 +130,50 @@ class CategoryWidgetNew extends Template implements BlockInterface $this->filterProvider = $filterProvider; $this->categoryWidgetFactory = $categoryWidgetFactory; $this->categoryWidgetRepository = $categoryWidgetRepository; - $this->imageRepository = $imageRepository; + $this->categoryRepository = $categoryRepository; $this->imageOptimizer = $imageOptimizer; $this->imageAdapterFactory = $imageAdapterFactory; parent::__construct($context, $data); $this->defaultSettings = [ - 'constrainOnly' => $this->_scopeConfig->getValue('Categorywidget/resize/constrain_only', ScopeInterface::SCOPE_STORE), - 'keepAspectRatio' => $this->_scopeConfig->getValue('Categorywidget/resize/keep_aspect_ratio', ScopeInterface::SCOPE_STORE), - 'keepTransparency' => $this->_scopeConfig->getValue('Categorywidget/resize/keep_transparency', ScopeInterface::SCOPE_STORE), - 'keepFrame' => $this->_scopeConfig->getValue('Categorywidget/resize/keep_frame', ScopeInterface::SCOPE_STORE), - 'backgroundColor' => $this->_scopeConfig->getValue('Categorywidget/resize/background_color', ScopeInterface::SCOPE_STORE), - 'identifier' => $this->_scopeConfig->getValue('Categorywidget/save/identifier', ScopeInterface::SCOPE_STORE), - 'basename' => $this->_scopeConfig->getValue('Categorywidget/save/basename', ScopeInterface::SCOPE_STORE), - 'width' => $this->_scopeConfig->getValue('Categorywidget/save/width', ScopeInterface::SCOPE_STORE), - 'height' => $this->_scopeConfig->getValue('Categorywidget/save/height', ScopeInterface::SCOPE_STORE), - 'compression' => $this->_scopeConfig->getValue('Categorywidget/save/compression', ScopeInterface::SCOPE_STORE) + 'constrainOnly' => $this->_scopeConfig->getValue('categorywidget/resize/constrain_only', ScopeInterface::SCOPE_STORE), + 'keepAspectRatio' => $this->_scopeConfig->getValue('categorywidget/resize/keep_aspect_ratio', ScopeInterface::SCOPE_STORE), + 'keepTransparency' => $this->_scopeConfig->getValue('categorywidget/resize/keep_transparency', ScopeInterface::SCOPE_STORE), + 'keepFrame' => $this->_scopeConfig->getValue('categorywidget/resize/keep_frame', ScopeInterface::SCOPE_STORE), + 'backgroundColor' => $this->_scopeConfig->getValue('categorywidget/resize/background_color', ScopeInterface::SCOPE_STORE), + 'identifier' => $this->_scopeConfig->getValue('categorywidget/save/identifier', ScopeInterface::SCOPE_STORE), + 'basename' => $this->_scopeConfig->getValue('categorywidget/save/basename', ScopeInterface::SCOPE_STORE), + 'width' => $this->_scopeConfig->getValue('categorywidget/save/width', ScopeInterface::SCOPE_STORE), + 'height' => $this->_scopeConfig->getValue('categorywidget/save/height', ScopeInterface::SCOPE_STORE), + 'compression' => $this->_scopeConfig->getValue('categorywidget/save/compression', ScopeInterface::SCOPE_STORE) ]; } /** - * Get Slider + * Get Widget * * @return CategoryWidgetModel */ - public function getSlider() + public function getWidget() { try { - /** @var CategoryWidgetModel $slider */ - $slider = $this->categoryWidgetRepository->getById($this->getId()); + /** @var CategoryWidgetModel $widget */ + $widget = $this->categoryWidgetRepository->getById($this->getId()); - return $slider; + return $widget; } catch (LocalizedException $e) { return null; } } /** - * Get Slider Content + * Get Items * * @param $content * @return array */ - public function getSliderContent(string $content) + public function getItems(string $content) { $array = explode('|', $content); $array = array_map('intval', $array); @@ -181,29 +181,31 @@ class CategoryWidgetNew extends Template implements BlockInterface $result = array(); foreach ($array as $image) { - array_push($result, $this->getImage((int)$image)); + array_push($result, $this->getCategory((int)$image)); } return $result; } /** - * Get Image + * Get Category * * @param int $id * @return array */ - private function getImage (int $id) + private function getCategory (int $id) { try { - /** @var ImageModel $image */ - $image = $this->imageRepository->getById($id); + /** @var CategoryModel $category */ + $category = $this->categoryRepository->get($id); $result = array(); - $result['id'] = $image->getId(); - $result['path'] = $image->getPath(); - $result['alt'] = $image->getAlt(); - $result['is_active'] = $image->isActive(); + $result['id'] = $category->getId(); + $result['is_active'] = $category->getIsActive(); + $result['name'] = $category->getName(); + $result['image_path'] = $category->getImageUrl('image'); + $result['description'] = $category->getCustomAttribute('description'); + $result['url'] = $category->getUrl(); return $result; } catch (LocalizedException $e) { @@ -251,6 +253,26 @@ class CategoryWidgetNew extends Template implements BlockInterface return $this->getData('title_tag'); } + /** + * Récupère le titre du Category Widget + */ + public function getActiveTitleElement() + { + if ($this->getData('active_title_element') === 'true') { + return true; + } + + return false; + } + + /** + * Récupère la balise pour le titre du Category Widget + */ + public function getWidgetTitleElementTag() + { + return $this->getData('title_element_tag'); + } + /** * Récupère la class CSS du titre du widget */ @@ -260,12 +282,40 @@ class CategoryWidgetNew extends Template implements BlockInterface } /** - * Récupère la valeur pour l'ajout d'un contenu + * Récupère la valeur pour l'ajout d'un contenu en haut + */ + public function getActiveContentTop() + { + if ($this->getWidgetContentTop() !== null) { + if ($this->getData('active_content_top') === 'true') { + return true; + } + + return false; + } + + return false; + } + + /** + * Récupère le contenu haut du widget */ - public function getActiveContent() + public function getWidgetContentTop() { - if ($this->getWidgetContent() !== null) { - if ($this->getData('active_content') === 'true') { + if (strlen($this->getData('content_top')) === 0) { + return false; + } + + return $this->getData('content_top'); + } + + /** + * Récupère la valeur pour l'ajout d'un contenu en bas + */ + public function getActiveContentBottom() + { + if ($this->getWidgetContentBottom() !== null) { + if ($this->getData('active_content_bottom') === 'true') { return true; } @@ -276,15 +326,15 @@ class CategoryWidgetNew extends Template implements BlockInterface } /** - * Récupère le contenu du widget + * Récupère le contenu bas du widget */ - public function getWidgetContent() + public function getWidgetContentBottom() { - if (strlen($this->getData('content')) === 0) { + if (strlen($this->getData('content_bottom')) === 0) { return false; } - return $this->getData('content'); + return $this->getData('content_bottom'); } /** @@ -411,6 +461,14 @@ class CategoryWidgetNew extends Template implements BlockInterface return $this->getData('link_target'); } + /** + * Récupère le contenu du lien + */ + public function getLinkContent() + { + return $this->getData('link_content'); + } + /** * Prepare and set resize settings for image * @@ -440,19 +498,13 @@ class CategoryWidgetNew extends Template implements BlockInterface */ public function getResizeImage($image, $width = null, $height = null, array $settings = []) { - $baseURL = $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA); - /* Si c'est pas un fichier JPG, on retourne l'original */ if (substr($image, -3) != 'jpg') { - return $baseURL . $image; - } - - /* Si il n'y a pas de resize activé, on retourne l'original */ - if ($this->getData('active_resize') === 'false') { - return $baseURL . $image; + return $image; } - $settings['basename'] = $image; + $basename = str_replace('/media/catalog/category/', '', $image); + $settings['basename'] = $basename; if ($image) { if (is_string($image)) { @@ -486,7 +538,7 @@ class CategoryWidgetNew extends Template implements BlockInterface try { return $this->imageOptimizer->getResizeImage($absolutePath, $dirPath->getAbsolutePath(''), $this->resizeSettings); } catch (Exception $e) { - return $baseURL . $image; + return $image; } } @@ -498,6 +550,7 @@ class CategoryWidgetNew extends Template implements BlockInterface */ public function getResizedImageWidth($imagePath) { + return $this->getWidth(); $dirPath = $this->filesystem->getDirectoryRead(DirectoryList::PUB); $absoluteImagePath = $dirPath->getAbsolutePath($imagePath); @@ -512,6 +565,7 @@ class CategoryWidgetNew extends Template implements BlockInterface */ public function getResizedImageHeight($imagePath) { + return $this->getHeight(); $dirPath = $this->filesystem->getDirectoryRead(DirectoryList::PUB); $absoluteImagePath = $dirPath->getAbsolutePath($imagePath); diff --git a/etc/widget.xml b/etc/widget.xml index f0a9f67..0f0537a 100755 --- a/etc/widget.xml +++ b/etc/widget.xml @@ -84,25 +84,81 @@ </options> </parameter> - <parameter name="active_content" xsi:type="select" visible="true" sort_order="40"> - <label translate="true">Activate text content?</label> + <parameter name="active_title_element" xsi:type="select" visible="true" sort_order="35"> + <label translate="true">Activate title element?</label> <options> - <option name="active_content_no" value="false"> + <option name="active_title_element_no" value="false"> <label translate="true">No</label> </option> - <option name="active_content_yes" value="true"> + <option name="active_title_element_yes" value="true"> <label translate="true">Yes</label> </option> </options> </parameter> - <parameter name="content" xsi:type="text" visible="true" sort_order="50"> - <label translate="true">Widget Content</label> + <parameter name="title_element_tag" xsi:type="select" visible="true" sort_order="40"> + <label translate="true">Title Tag</label> + <depends> + <parameter name="active_title_element" value="true"/> + </depends> + <options> + <option name="title_element_tag_h1" value="h1"> + <label translate="true">H1</label> + </option> + <option name="title_element_tag_h2" value="h2" selected="true"> + <label translate="true">H2</label> + </option> + <option name="title_element_tag_h3" value="h3"> + <label translate="true">H3</label> + </option> + <option name="title_element_tag_h4" value="h4"> + <label translate="true">H4</label> + </option> + <option name="title_element_tag_h5" value="h5"> + <label translate="true">H5</label> + </option> + <option name="title_element_tag_h6" value="h6"> + <label translate="true">H6</label> + </option> + </options> + </parameter> + + <parameter name="active_content_top" xsi:type="select" visible="true" sort_order="50"> + <label translate="true">Activate content top?</label> + <options> + <option name="active_content_top_no" value="false"> + <label translate="true">No</label> + </option> + <option name="active_content_top_yes" value="true"> + <label translate="true">Yes</label> + </option> + </options> + </parameter> + <parameter name="content_top" xsi:type="text" visible="true" sort_order="51"> + <label translate="true">Content Top</label> + <depends> + <parameter name="active_content_top" value="true"/> + </depends> + </parameter> + + <parameter name="active_content_bottom" xsi:type="select" visible="true" sort_order="55"> + <label translate="true">Activate content bottom?</label> + <options> + <option name="active_content_bottom_no" value="false"> + <label translate="true">No</label> + </option> + <option name="active_content_bottom_yes" value="true"> + <label translate="true">Yes</label> + </option> + </options> + </parameter> + <parameter name="content_bottom" xsi:type="text" visible="true" sort_order="56"> + <label translate="true">Content Bottom</label> <depends> - <parameter name="active_content" value="true"/> + <parameter name="active_content_bottom" value="true"/> </depends> </parameter> - <parameter name="id" xsi:type="block" visible="true" required="true" sort_order="60"> + <parameter name="id" xsi:type="block" visible="true" required="true" sort_order="70"> <label translate="true">Category Widget</label> <block class="NicolasBejean\CategoryWidget\Block\Adminhtml\CategoryWidget\Widget\Chooser"> <data> @@ -113,38 +169,17 @@ </block> </parameter> - <parameter name="active_resize" xsi:type="select" visible="true" required="true" sort_order="70"> - <label translate="true">Activate photo resize?</label> - <description translate="true">JPG image only</description> - <options> - <option name="active_resize_no" value="false"> - <label translate="true">No</label> - </option> - <option name="active_resize_yes" value="true"> - <label translate="true">Yes</label> - </option> - </options> - </parameter> <parameter name="width" xsi:type="text" visible="true" sort_order="80"> <label translate="true">Image width</label> <description translate="true">Numbers in px - Default: 1920</description> - <depends> - <parameter name="active_resize" value="true"/> - </depends> </parameter> <parameter name="height" xsi:type="text" visible="true" sort_order="90"> <label translate="true">Image height</label> <description translate="true">Numbers in px - Default: 1080</description> - <depends> - <parameter name="active_resize" value="true"/> - </depends> </parameter> <parameter name="quality" xsi:type="text" visible="true" sort_order="100"> <label translate="true">Compression</label> <description translate="true">Number in % - Default: 60</description> - <depends> - <parameter name="active_resize" value="true"/> - </depends> </parameter> <parameter name="css_classes" xsi:type="text" visible="true" sort_order="130"> @@ -212,6 +247,12 @@ </option> </options> </parameter> + <parameter name="link_content" xsi:type="text" visible="true" sort_order="210"> + <label translate="true">Content</label> + <depends> + <parameter name="active_link" value="true"/> + </depends> + </parameter> </parameters> </widget> </widgets> diff --git a/view/frontend/layout/default.xml b/view/frontend/layout/default.xml index 92a68c4..8ef7263 100644 --- a/view/frontend/layout/default.xml +++ b/view/frontend/layout/default.xml @@ -1,7 +1,8 @@ <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> - <css src="NicolasBejean_ImageSliderManager::css/glide.core.css" /> - <css src="NicolasBejean_ImageSliderManager::css/glide.theme.css" /> + <css src="NicolasBejean_CategoryWidget::css/glide.core.css" /> + <css src="NicolasBejean_CategoryWidget::css/glide.theme.css" /> + <css src="NicolasBejean_CategoryWidget::css/category-widget.css" /> </head> </page> diff --git a/view/frontend/templates/widget/categorywidget/default.phtml b/view/frontend/templates/widget/categorywidget/default.phtml index c187c77..c56587e 100755 --- a/view/frontend/templates/widget/categorywidget/default.phtml +++ b/view/frontend/templates/widget/categorywidget/default.phtml @@ -1,26 +1,31 @@ <?php +use \NicolasBejean\CategoryWidget\Block\Widget\CategoryWidgetNew; -use \NicolasBejean\CategoryWidget\Block\Widget\CategoryWidget; - -/** @var CategoryWidget $block */ -$slider = $block->getSlider(); -$sliderContent = $block->getSliderContent($slider->getContent()); -$active = $slider->isActive(); +/** @var CategoryWidgetNew $block */ +$widget = $block->getWidget(); +$content = $block->getItems($widget->getContent()); +$active = $widget->isActive(); $activeTitle = $block->getActiveTitle(); -$activeContent = $block->getActiveContent(); -$activeWrapper = $block->getActiveImageWrapper(); +$activeTitleElement = $block->getActiveTitleElement(); +$activeContentTop = $block->getActiveContentTop(); +$activeContentBottom = $block->getActiveContentBottom(); +$activeWrapper = $block->getActiveWrapper(); $activeLink = $block->getActiveLink(); +$activeSlider = false; + if ($active) { - $imageCollection = []; + $collection = []; $iteration = 0; - foreach ($sliderContent as $image) { - if ($image['is_active']) { - $imageCollection[$iteration]['path'] = $block->getResizeImage($image['path'], $block->getWidth(), $block->getHeight()); - $imageCollection[$iteration]['width'] = $block->getResizedImageWidth($imageCollection[$iteration]['path']); - $imageCollection[$iteration]['height'] = $block->getResizedImageHeight($imageCollection[$iteration]['path']); - $imageCollection[$iteration]['alt'] = $image['alt']; + foreach ($content as $item) { + if ($item['is_active'] && $item['image_path'] !== false) { + $collection[$iteration]['name'] = $item['name']; + $collection[$iteration]['description'] = $item['description']; + $collection[$iteration]['url'] = $item['url']; + $collection[$iteration]['image_path'] = $block->getResizeImage($item['image_path'], $block->getWidth(), $block->getHeight()); + $collection[$iteration]['width'] = $block->getResizedImageWidth($collection[$iteration]['image_path']); + $collection[$iteration]['height'] = $block->getResizedImageHeight($collection[$iteration]['image_path']); } $iteration++; } @@ -29,55 +34,79 @@ if ($active) { <?php if ($active): ?> <?php if ($activeWrapper): ?> - <div class="imageslidermanager <?php if ($block->getWrapperCssClasses()): ?><?= /* @noEscape */ $block->getWrapperCssClasses(); ?><?php endif; ?>"> + <div class="categorywidget <?php if ($block->getWrapperCssClasses()): ?><?= /* @noEscape */ $block->getWrapperCssClasses(); ?><?php endif; ?>"> <?php endif; ?> <?php if ($activeTitle || $activeContent): ?> - <div class="imageslidermanager-title-content <?php if ($block->getWidgetTitleCSS()): ?><?= /* @noEscape */ $block->getWidgetTitleCSS(); ?><?php endif; ?>"> + <div class="categorywidget-title-content <?php if ($block->getWidgetTitleCSS()): ?><?= /* @noEscape */ $block->getWidgetTitleCSS(); ?><?php endif; ?>"> <?php if ($activeTitle): ?> - <<?= /* @noEscape */ $block->getWidgetTitleTag(); ?>><?= /* @noEscape */ $block->getWidgetTitle() ?></<?= /* @noEscape */ $block->getWidgetTitleTag(); ?>> + <<?= /* @noEscape */ $block->getWidgetTitleTag(); ?>><?= /* @noEscape */ $block->getWidgetTitle(); ?></<?= /* @noEscape */ $block->getWidgetTitleTag(); ?>> <?php endif; ?> - <?php if ($activeContent): ?> - <p class="<?php if ($block->getWidgetContentCSS()): ?><?= /* @noEscape */ $block->getWidgetContentCSS(); ?><?php endif; ?>"><?= /* @noEscape */ $block->getWidgetContent(); ?></p> + <?php if ($activeTitleElement): ?> + <<?= /* @noEscape */ $block->getWidgetTitleElementTag(); ?>><?= /* @noEscape */ $widget->getTitle(); ?></<?= /* @noEscape */ $block->getWidgetTitleElementTag(); ?>> + <?php endif; ?> + <?php if ($activeContentTop): ?> + <p class="categorywidget-content-top <?php if ($block->getWidgetContentCSS()): ?><?= /* @noEscape */ $block->getWidgetContentCSS(); ?><?php endif; ?>"><?= /* @noEscape */ $block->getWidgetContentTop(); ?></p> <?php endif; ?> </div> <?php endif; ?> - <?php if ($activeLink): ?> - <a href="<?= /* @noEscape */ $block->getLinkHref(); ?>" target="<?= /* @noEscape */ $block->getLinkTarget(); ?>"> - <?php endif; ?> - - <div class="imageslidermanager-imageslider glide hero" style="width: <?= /* @noEscape */ $block->getWidth(); ?>px; height: <?= /* @noEscape */ $block->getHeight(); ?>px;"> + <?php if ($activeSlider): ?> + <div class="categorywidget-slider glide hero" style="width: <?= /* @noEscape */ $block->getWidth(); ?>px; height: <?= /* @noEscape */ $block->getHeight(); ?>px;"> <div class="glide__track" data-glide-el="track"> <ul class="glide__slides"> - <?php foreach ($imageCollection as $image) : ?> + <?php foreach ($collection as $item) : ?> <li class="glide__slide"> - <img src="<?php echo /* @noEscape */ $image['path']; ?>" + <img src="<?php echo /* @noEscape */ $item['image_path']; ?>" <?php if ($block->getCssClasses()): ?>class="<?= /* @noEscape */ $block->getCssClasses(); ?>"<?php endif; ?> - alt="<?= /* @noEscape */ $image['alt']; ?>" + alt="<?= /* @noEscape */ $item['name']; ?>" <?php if ($block->getExtraCss()): ?>style="<?= /* @noEscape */ $block->getExtraCss(); ?>"<?php endif; ?> <?php if ($block->getDataBind()): ?>data-bind="<?= /* @noEscape */ $block->getDataBind(); ?>"<?php endif; ?> - width="<?= /* @noEscape */ $image['width']; ?>" - height="<?= /* @noEscape */ $image['height']; ?>" + width="<?= /* @noEscape */ $item['width']; ?>" + height="<?= /* @noEscape */ $item['height']; ?>" /> </li> <?php endforeach; ?> </ul> </div> - <?php if (count($sliderContent) > 1): ?> + <?php if (count($content) > 1): ?> <div class="glide__arrows" data-glide-el="controls"> <button class="glide__arrow glide__arrow--prev" data-glide-dir="<">prev</button> <button class="glide__arrow glide__arrow--next" data-glide-dir=">">next</button> </div> <?php endif; ?> </div> + <?php endif; ?> + + <?php if (!$activeSlider): ?> + <div class="categorywidget-collection"> + <?php foreach ($collection as $item) : ?> + <a class="categorywidget-category-link" href="<?= /* @noEscape */ $item['url']; ?>" target="_self"> + <span class="categorywidget-category-image <?php if ($block->getImageCssClasses()): ?><?= /* @noEscape */ $block->getImageCssClasses(); ?><?php endif; ?>" + style="background-image: url('<?php echo /* @noEscape */ $item['image_path']; ?>'); width: <?= /* @noEscape */ $item['width']; ?>px; height: calc(<?= /* @noEscape */ $item['height']; ?>px + 20px); + <?php if ($block->getImageExtraCss()): ?><?= /* @noEscape */ $block->getImageExtraCss(); ?><?php endif; ?>" + > + <span class="categorywidget-category-name"> + <?= /* @noEscape */ $item['name']; ?> + </span> + </span> + </a> + <?php endforeach; ?> + </div> + <?php endif; ?> + + <?php if ($activeContentBottom): ?> + <p class="categorywidget-content-bottom <?php if ($block->getWidgetContentCSS()): ?><?= /* @noEscape */ $block->getWidgetContentCSS(); ?><?php endif; ?>"><?= /* @noEscape */ $block->getWidgetContentBottom(); ?></p> + <?php endif; ?> <?php if ($activeLink): ?> - </a> + <div class="categorywidget-link"> + <a href="<?= /* @noEscape */ $block->getLinkHref(); ?>" target="<?= /* @noEscape */ $block->getLinkTarget(); ?>"><?= /* @noEscape */ $block->getLinkContent(); ?></a> + </div> <?php endif; ?> <?php if ($activeWrapper): ?> </div> <?php endif; ?> - <?php if (count($sliderContent) > 1): ?> + <?php if (count($content) > 1 && $activeSlider): ?> <script> require(['jquery', 'NicolasBejean_CategoryWidget/js/glide', 'domReady!'], function($, Glide){ new Glide('.glide').mount(); -- GitLab