I have a problem integrating https://github.com/variar/grav-plugin-unitegallery in my twig templates of a theme inheriting from Quark. The pages are generated by converting an old TYPO3 site and have lots of galleries on part of the pages.
So I added an empty block named galleries
to partials/base.html.twig
and modified default.html.twig
in this way:
{% extends 'partials/base.html.twig' %}
{% macro pageLinkName(text) %}{{ text|lower|replace({' ':'_'}) }}{% endmacro %}
{% block content %}
{{ page.content }}
{% endblock %}
{% block galleries %}
<div class="galleries">
{% for module in page.collection('galleries') if module.template == 'modular/gallery' %}
<div id="{{ _self.pageLinkName(module.menu) }}"></div>
{{ module.content }}
{% endfor %}
</div>
{% endblock %}
modular/gallery.html.twig
is
{% set grid_size = theme_var('grid-size') %}
{% set columns = page.header.class == 'small' ? 'col-3 col-md-4 col-sm-6' : 'col-4 col-md-6 col-sm-12' %}
{% set gallery_id = (page.header.unitegallery.gallery_id ?: page.slug|ltrim('_')) %}
{% set gallery_theme = page.parent.header.unitegallery.gallery_theme ?: 'tiles' %}
{% set gallery_options = { 'gallery_theme': gallery_theme } %}
{{ page.content }}
<div class="gallery-container {{ page.header.class }}">
{{ unite_gallery(page.media.images, gallery_options|json_encode, gallery_id) }}
</div>
The problem is in the {{ module.content }}
call in default.html.twig
: If the markdown of the modular gallery page is not empty every thing works as expected. If the markdown is empty, only with a frontmatter in the md file, nothing of the modular template is rendered and even the debugger does not show up on the displayed page. With no error in logs, console and no debugger I am not sure what happened. If I add just one line of content everything works as expected.
The problem is not a gallery problem, I know how to handle them, and the problem is the same if I omit the gallery call and just render some dummy html.
Why is the subpage not rendered if it has an empty content? Because of the missing debugger output I think of a bug, not of a problem of misunderstanding twig rendering and caching. Am I right?
What must I do to fix this? Should I create an issue?
Additional information: In the frontmatter of the containing page I have
galleries:
items: '@self.modular'
unitegallery:
gallery_theme: tiles
Newest grav 1.4.7
Update 22.07.2018:
No errors was not true, i looked into a another apache log, not the right one. Error there was:
[Sun Jul 22 09:59:00.787786 2018] [:error] [pid 3152] [client 84.57.9.254:4906] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/domains/saint-josse-europe.eu/grav/system/src/Grav/Common/Plugin.php on line 265
[Sun Jul 22 09:59:00.788029 2018] [:error] [pid 3152] [client 84.57.9.254:4906] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/domains/saint-josse-europe.eu/grav/vendor/monolog/monolog/src/Monolog/Logger.php on line 416
After increasing memory to 256 MB still errors, but in other routines:
[Sun Jul 22 10:06:23.521845 2018] [:error] [pid 3695] [client 84.57.9.254:5300] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in /var/www/domains/saint-josse-europe.eu/grav/vendor/symfony/event-dispatcher/Event Dispatcher.php on line 184
[Sun Jul 22 10:06:23.522013 2018] [:error] [pid 3695] [client 84.57.9.254:5300] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in /var/www/domains/saint-josse-europe.eu/grav/vendor/filp/whoops/src/Whoops/Run.php
Think it is an infinite loop somehow. Will look deeper.