DMAGmbH / dma_elementgenerator

DMA Elementgenerator (Contao)
45 stars 17 forks source link

Bilder verwenden die gleiche Lightbox #74

Closed thepixture closed 8 years ago

thepixture commented 9 years ago

Legt man mehrere gleiche Inhaltselemente an, die ein Feld vom Typ "image" haben, dann wird, bei Verwendung einer Lightbox, von allen Bildern die gleiche Lightbox verwendet. Man kann also zwischen den Bildern der einzelnen Inhaltselemente durchschalten.

Es wäre optimaler hier für jedes Inhaltselement ein eigenes data-lightbox-attribut zu verwenden. Wenn mehrere Bilder innerhalb des Inhaltselements angelegt wurden, dann kann schon die gleiche Lightbox verwendet werden.

JanoschSkuplik commented 9 years ago

Alles klar. Gucke ich mir an. Evtl. schleife ich die Element-ID mit durch, damit die eindeutig werden.

JensenR commented 9 years ago

Hallo, gibt es da schon eine Lösung?

crackmama commented 8 years ago

Hallo, gibt es dazu vielleicht bereits eine Lösung? Weil das würde mich auch brennend interessieren.

fritzmg commented 8 years ago

The problem is, that DMA Elementgenerator does not feed the \Controller::addImageToTemplate function with enough data. The function generates a unique value for the data-lightbox attribute, using the FrontendTemplate's name and the ID of the element itself: contao/core/blob/3.5.6/system/modules/core/library/Contao/Controller.php#L1531

$strLightboxId = 'lightbox[' . substr(md5($objTemplate->getName() . '_' . $arrItem['id']), 0, 6) . ']';

However, DMA Elementgenerator only passes the singleSRC attribute and nothing else:

To fix this, you also need to add the content element's ID to this array.