Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

Page collection of pages and modules > module.summary

Started by sbstn 9 years ago · 0 replies · 1231 views
9 years ago

Hey folks,
i hope someone can help me with my issue.
i have a folder containing a bunch of normal pages and modular pages like:

main folder

  • normal page 1
  • normal page 2
  • modular page 1
    • _modular sub 1 (contains the content)
    • _modular sub 2
  • normal page 3
  • modular page 1
    • _modular sub 1 (contains the content)
    • _modular sub 2

i am going to output as usual via page.collection:

TWIG
{% for page in page.collection %}
  <a href="{{ page.url }}">{{ page.title }}</a>
  {{ page.summary }}
{% endfor %}

Works fine, but obviously for the modular pages the link is shown, but not the content/summary - as this is in the modular.
So i extend my page.collection to find the modules and output them:

TWIG
{% for page in page.collection %}
  {% if (page.template == 'modular') %}
    {% for module in page.collection %}
      {% if loop.index == 1 %}
        <a href="{{ page.url }}">{{ page.title }}</a>
        {{ module.summary }}
      {% endif %}
    {% endfor %}
  {% else %}
  <a href="{{ page.url }}">{{ page.title }}</a>
  {{ page.summary }}
  {% endif %}
{% endfor %}

result is that in case of module all the content as html is generated. after some research (like /forum/archive/content-without-summary-t3240) i changed to:

TWIG
{% for page in page.collection %}
  {% if (page.template == 'modular') %}
    {% for module in page.collection %}
      {% if loop.index == 1 %}
        <a href="{{ page.url }}">{{ page.title }}</a>
        {% set content = module.content|slice(module.title|length) %}
        {{ module.content }}
      {% endif %}
    {% endfor %}
  {% else %}
  <a href="{{ page.url }}">{{ page.title }}</a>
  {{ page.summary }}
  {% endif %}
{% endfor %}

unfortunaly the result ist still the same - the raw summary is not rendered but the whole html.
any ideas, what i am doing wrong?

cheers, seb

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 94 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 184 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 146 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 60 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 254 1 year ago