1

I am making a Grav template from a static html. This is a one-pager, so I am using modular templates and content. The problem is that I have a gallery, and my clicking on an image, a modal pops up. The code for the modals are places outside the container I am using for the image gallery.

Is there a way to have a twig modular template creating output code two different places on the base template? I have tried using multiple blocks in the modular template, but in the final output all code are places inside the image gallery container? My templates have multiple level nesting just to make it a little bit easier:

  • main
    • Listing of categories
      • Listing of images for each category

base.html.twig (simplified):

{% block body %}
  {% block modal %}{% endblock %}
  {% block content %}{% endblock %}
{% endblock %}

modular.html.twig:

{% extends 'partials/base.html.twig' %}
{% block content %}
    {{ page.content }}
    {% for module in page.collection() %}
        <div id="{{ _self.pageLinkName(module.menu) }}">
          {{ module.content }}
        </div>
    {% endfor %}
{% endblock %}

category-list.html.twig (simplified):

 {% block content %}
   {% for module in page.collection() %}
      {{ module.content }}
   {% endfor %}
 {% endblock %}

content template (simplified):

{% block modal %}
  {{ page.titel }}
{% endblock %}

{% block content %}
  {{ page.content }}
{% endblock %}

My problem: rendering the block modal from the content template in the block Modal in the base template. Currently the block modal is rendered in block content.

Any ideas?

Thanks

dr. squid
  • 786
  • 2
  • 6
  • 14
  • 1
    I don't understand your question. What problem are you having exactly? – Jacobm001 Nov 16 '17 at 23:27
  • 1
    In the content template (last code example), I need the modal block content to be rendered inside the modal block in the base template. But now the modal content is rendered in the content block in the base template – dr. squid Nov 16 '17 at 23:31

0 Answers0