Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 3fcfc8a0 authored by Nicolas's avatar Nicolas
Browse files

Mise en place du champ type de template dans le widget

parent 43f36cb6
No related branches found
No related tags found
No related merge requests found
......@@ -221,6 +221,18 @@ class CategoryWidgetNew extends Template implements BlockInterface
return $this->getData('id');
}
/**
* Récupère le type de template du widget
*/
public function getTemplateType()
{
if ($this->getData('template_type') === '' || is_null($this->getData('template_type'))) {
return 'collection';
}
return $this->getData('template_type');
}
/**
* Récupère la valeur pour l'ajout d'un titre
*/
......@@ -550,7 +562,6 @@ class CategoryWidgetNew extends Template implements BlockInterface
*/
public function getResizedImageWidth($imagePath)
{
return $this->getWidth();
$dirPath = $this->filesystem->getDirectoryRead(DirectoryList::PUB);
$absoluteImagePath = $dirPath->getAbsolutePath($imagePath);
......@@ -565,7 +576,6 @@ class CategoryWidgetNew extends Template implements BlockInterface
*/
public function getResizedImageHeight($imagePath)
{
return $this->getHeight();
$dirPath = $this->filesystem->getDirectoryRead(DirectoryList::PUB);
$absoluteImagePath = $dirPath->getAbsolutePath($imagePath);
......
......@@ -40,6 +40,10 @@
<label translate="true">Widget: Category Widget --- NEW</label>
<description translate="true">Category Widget Description</description>
<parameters>
<parameter name="template_type" xsi:type="text" visible="true" sort_order="5">
<label translate="true">Template type</label>
<description translate="true">Default: collection | Choice: collection, slider | Or Create Yours</description>
</parameter>
<parameter name="active_title" xsi:type="select" visible="true" sort_order="10">
<label translate="true">Activate title?</label>
<options>
......
......@@ -10,10 +10,9 @@ $activeTitleElement = $block->getActiveTitleElement();
$activeContentTop = $block->getActiveContentTop();
$activeContentBottom = $block->getActiveContentBottom();
$activeWrapper = $block->getActiveWrapper();
$templateType = $block->getTemplateType();
$activeLink = $block->getActiveLink();
$activeSlider = false;
if ($active) {
$collection = [];
$iteration = 0;
......@@ -50,7 +49,24 @@ if ($active) {
</div>
<?php endif; ?>
<?php if ($activeSlider): ?>
<?php if ($templateType === 'collection'): ?>
<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 ($templateType === 'slider'): ?>
<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">
......@@ -69,31 +85,14 @@ if ($active) {
</ul>
</div>
<?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>
<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; ?>
......@@ -106,7 +105,7 @@ if ($active) {
<?php if ($activeWrapper): ?>
</div>
<?php endif; ?>
<?php if (count($content) > 1 && $activeSlider): ?>
<?php if (count($content) > 1 && $templateType === 'slider'): ?>
<script>
require(['jquery', 'NicolasBejean_CategoryWidget/js/glide', 'domReady!'], function($, Glide){
new Glide('.glide').mount();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment