Skip to content

Commit

Permalink
Update gallery.html.twig
Browse files Browse the repository at this point in the history
  • Loading branch information
heimseiten authored Oct 23, 2023
1 parent 5795d54 commit 5b8f119
Showing 1 changed file with 39 additions and 17 deletions.
56 changes: 39 additions & 17 deletions contao/templates/content_element/gallery.html.twig
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
<?php
{% extends "@Contao/content_element/gallery.html.twig" %}

use Contao\CoreBundle\DataContainer\PaletteManipulator;
use Contao\DataContainer;
{% set imageHeight = '0' %}

$GLOBALS['TL_DCA']['tl_content']['fields']['use_flex_gallery_image'] = [
'label' => &$GLOBALS['TL_LANG']['tl_content']['use_flex_gallery_image'],
'inputType' => 'checkbox',
'search' => true,
'eval' => array('tl_class' => 'w50'),
'sql' => array('type' => 'boolean', 'default' => false)
];
{% block figure_component %}
{% if figure.image.img.width %}
{% if figure.image.img.height %}
{% set figure_attributes = attrs()
.set('data-w', figure.image.img.width)
.set('data-h', figure.image.img.height)
%}
{% set figure_attributes = attrs(figure_attributes|default).addClass('item') %}
{% endif %}
{% endif %}
{{ parent() }}
{% set imageHeight = figure.image.img.height %}
{{ app.session.set('imageHeight', imageHeight) }}
{% endblock %}

$GLOBALS['TL_DCA']['tl_content']['fields']['perRow']['eval']['tl_class'] = 'w25 hidden';
$GLOBALS['TL_DCA']['tl_content']['fields']['perPage']['eval']['tl_class'] = 'w25';
$GLOBALS['TL_DCA']['tl_content']['fields']['numberOfItems']['eval']['tl_class'] = 'w25';
{% block content %}
<div class="flex-images fleximages_{{ data.id }}">
{{ parent() }}
</div>
{% endblock %}

PaletteManipulator::create()
->addField('use_flex_gallery_image', 'image_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('gallery', 'tl_content')
;
{% block wrapper %}
{{ parent() }}
{% set maxHeight = '180' %}
{% if data.flex_gallery_image_height %}
{% set maxHeight = data.flex_gallery_image_height %}
{% endif %}
{% set imageHeight = app.session.get('imageHeight') %}
{% set assembledScript = '<script> new flexImages({ selector: ".fleximages_' ~ data.id ~ '", rowHeight: "' ~ imageHeight ~ '" }); </script>' %}
{{ assembledScript|raw }}
{% endblock %}

{% block list %}
{% for item in list.items %}
{%- block list_item %}
{{ parent() }}
{% endblock -%}
{% endfor %}
{% endblock %}

0 comments on commit 5b8f119

Please sign in to comment.