Browse code

Add image slide lightbox gallery feature

Benjamin Roth authored on23/09/2019 16:13:06
Showing4 changed files
... ...
@@ -58,6 +58,16 @@ class ContentSlickSliderImage extends \ContentElement
58 58
       return $return;
59 59
     }
60 60
 
61
+    $parentKey = ($this->arrData['ptable'] ?: 'tl_article') . '__' . $this->arrData['pid'];
62
+
63
+    if (isset($GLOBALS['TL_ESM_SLICK'][$parentKey]))
64
+    {
65
+      $this->arrData['parentSlickId'] = $GLOBALS['TL_ESM_SLICK'][$parentKey];
66
+    } else {
67
+      $this->arrData['parentSlickId'] = 0;
68
+    }
69
+
70
+
61 71
     return parent::generate();
62 72
   }
63 73
 
... ...
@@ -172,6 +182,7 @@ class ContentSlickSliderImage extends \ContentElement
172 182
 
173 183
     if ($this->eSM_slick_addImageLink)
174 184
     {
185
+      $this->Template->lightboxId = 'image_slide_' . ($this->parentSlickId ?: 's'.$this->id);
175 186
       $this->Template->fullsize = $this->fullsize;
176 187
       $this->Template->imageLink = ($this->imageUrl ?: $this->singleSRC);
177 188
     }
... ...
@@ -40,6 +40,14 @@ class ContentSlickSliderStart extends \ContentElement
40 40
 			$this->Template->title = $this->headline;
41 41
 		}
42 42
 
43
+    $parentKey = ($this->arrData['ptable'] ?: 'tl_article') . '__' . $this->arrData['pid'];
44
+
45
+    if (!empty($GLOBALS['TL_ESM_SLICK'][$parentKey])) {
46
+      $GLOBALS['TL_ESM_SLICK_STACK'][$parentKey][] = $GLOBALS['TL_ESM_SLICK'][$parentKey];
47
+    }
48
+
49
+    $GLOBALS['TL_ESM_SLICK'][$parentKey] = $this->id;
50
+
43 51
 		// Slider configuration
44 52
 		$this->Template->config = $this->eSM_slick_autoPlaySpeed . ',' . $this->eSM_slick_speed . ',' . $this->eSM_slick_initialSlide . ',' . $this->eSM_slick_lazyLoad . ',' . $this->eSM_slick_infinite . ',' . $this->eSM_slick_arrows . ',' . $this->eSM_slick_pagination . ',' . $this->eSM_slick_pause . ',' . $this->eSM_slick_fade . ',' . $this->eSM_slick_slidesToShow . ',' . $this->eSM_slick_slidesToScroll . ',' . $this->eSM_slick_adaptiveHeight;
45 53
 
... ...
@@ -23,8 +23,27 @@ class ContentSlickSliderStop extends \ContentElement
23 23
 	 */
24 24
 	protected $strTemplate = 'ce_slick_slider_stop';
25 25
 
26
+  public function generate()
27
+  {
28
+    if (TL_MODE === 'BE') {
29
+      return parent::generate();
30
+    }
26 31
 
27
-	/**
32
+    $parentKey = ($this->arrData['ptable'] ?: 'tl_article') . '__' . $this->arrData['pid'];
33
+
34
+    if (isset($GLOBALS['TL_ESM_SLICK'][$parentKey])) {
35
+      unset($GLOBALS['TL_ESM_SLICK'][$parentKey]);
36
+    }
37
+
38
+    if (!empty($GLOBALS['TL_ESM_SLICK_STACK'][$parentKey])) {
39
+      $GLOBALS['TL_ESM_SLICK'][$parentKey] = array_pop($GLOBALS['TL_ESM_SLICK_STACK'][$parentKey]);
40
+    }
41
+
42
+    return parent::generate();
43
+  }
44
+
45
+
46
+  /**
28 47
 	 * Generate the content element
29 48
 	 */
30 49
 	protected function compile()
... ...
@@ -26,7 +26,7 @@
26 26
 
27 27
   </div>
28 28
   <?php if ($this->link || $this->imageLink): ?>
29
-    <a class="slide-url" href="<?= ($this->link ?: $this->imageLink) ?>"<?php if ($this->fullsize): ?> data-lightbox="image_slide_<?= $this->id ?>"<?php endif; ?>></a>
29
+    <a class="slide-url" href="<?= ($this->link ?: $this->imageLink) ?>"<?php if ($this->fullsize): ?> data-lightbox="<?= $this->lightboxId ?>"<?php endif; ?>></a>
30 30
   <?php endif; ?>
31 31
 </div>
32 32