Browse Source

fix https://assistance.opentalent.fr/browse/V8-1481

Olivier Massot 5 years ago
parent
commit
6e79a65daa

+ 49 - 0
ot_templating/Classes/ViewHelpers/Utilities/CountViewHelper.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace Opentalent\OtTemplating\ViewHelpers\Utilities;
+
+use Closure;
+use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
+use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
+
+/**
+ *   Returns the number of elements of an array
+ *
+ *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}
+ *
+ *     {ot:utilities.count('{k: v}')}
+ *
+ * @package Opentalent\OtTemplating\ViewHelpers
+ */
+class CountViewHelper extends AbstractViewHelper {
+
+    /**
+     * -- This method is expected by Fluid --
+     * Declares the viewhelper's parameters
+     */
+    public function initializeArguments()
+    {
+        $this->registerArgument('array',
+            'array',
+            "The array",
+            true);
+    }
+
+    /**
+     * -- This method is expected by Fluid --
+     * Renders the content as html
+     *
+     * @param array $arguments
+     * @param Closure $renderChildrenClosure
+     * @param RenderingContextInterface $renderingContext
+     * @return string|null
+     */
+    public static function renderStatic(
+        array $arguments,
+        Closure $renderChildrenClosure,
+        RenderingContextInterface $renderingContext
+    ) {
+        $array = $arguments['array'];
+        return count($array);
+    }
+}

+ 10 - 9
ot_templating/Resources/Private/Partials/Classic/Carousel.html

@@ -5,14 +5,15 @@
     Voir: https://fluidtypo3.org/viewhelpers/vhs/master/Page/Resources/FalViewHelper.html
 --></f:comment>
 
-<div class="carousel">
-    <v:page.resources.fal table="pages"
-                          field="media"
-                          uid="{page.uid}"
-                          as="images"
-                          slide="-1"
-                          limit="10"  >
 
+<v:page.resources.fal table="pages"
+                      field="media"
+                      uid="{page.uid}"
+                      as="images"
+                      slide="-1"
+                      limit="10"  >
+
+    <div class="carousel">
         <f:for each="{images}" as="image">
             <div>
                 <f:image src="{image.url}"
@@ -23,6 +24,6 @@
                 />
             </div>
         </f:for>
+    </div>
+</v:page.resources.fal>
 
-    </v:page.resources.fal>
-</div>

+ 30 - 12
ot_templating/Resources/Private/Partials/Modern/Carousel.html

@@ -1,4 +1,5 @@
 {namespace v=FluidTYPO3\Vhs\ViewHelpers}
+{namespace ot=Opentalent\OtTemplating\ViewHelpers}
 
 <f:comment><!--
     -- Resources.fal ViewHelper --
@@ -6,16 +7,33 @@
 --></f:comment>
 
 <section id="main-carousel" class="rev-slider">
-    <div id="rev_slider_268_1_wrapper" class="rev_slider_wrapper fullwidthbanner-container" data-alias="webster-slider-2" data-source="gallery" style="margin:0px auto;background:transparent;padding:0px;margin-top:0px;margin-bottom:0px;">
-        <f:comment><!-- START REVOLUTION SLIDER 5.4.6.3 fullwidth mode --></f:comment>
-        <div id="rev_slider_268_1" class="rev_slider" style="display:none;" data-version="5.4.6.3">
-
-            <v:page.resources.fal table="pages"
-                                  field="media"
-                                  uid="{page.uid}"
-                                  as="images"
-                                  slide="-1"
-                                  limit="10"  >
+    <div id="rev_slider_268_1_wrapper"
+         class="rev_slider_wrapper fullwidthbanner-container"
+         data-alias="webster-slider-2"
+         data-source="gallery"
+         style="margin:0px auto;background:transparent;padding:0px;margin-top:0px;margin-bottom:0px;">
+
+        <v:page.resources.fal table="pages"
+                              field="media"
+                              uid="{page.uid}"
+                              as="images"
+                              slide="-1"
+                              limit="10"  >
+
+            <f:if condition="{ot:utilities.count(array: images)} <= 1">
+                <style>
+                    .tparrows {
+                        display: none !important;
+                    }
+                </style>
+            </f:if>
+
+            <f:comment><!-- START REVOLUTION SLIDER 5.4.6.3 fullwidth mode --></f:comment>
+            <div id="rev_slider_268_1"
+                 class="rev_slider"
+                 style="display:none;"
+                 data-version="5.4.6.3">
+
                 <ul>
                     <f:for each="{images}" as="image">
 
@@ -52,7 +70,7 @@
 
                     </f:for>
                 </ul>
-            </v:page.resources.fal>
-        </div>
+            </div>
+        </v:page.resources.fal>
     </div>
 </section>