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

How to iterate modules written in md header

Started by Muut Archive 10 years ago · 2 replies · 357 views
10 years ago

Hi all. Will start from the question. How to print out md header content correctly without hardcoding the path with /components/ folder. PS. We need to use the components folder, so that the site structure is clear to the client to edit.

We have the following site structure in admin panel:
Screen Shot 2016-07-04 at 13
In frontpage.md we define the content which will be printed out on the frontpage.html.twig

YAML
title: Home
published: true
content:
    items:
      - '@page.self': '/components/_certificates'
      - '@page.self': '/components/_partners'
      - '@page.self': '/components/_services'

the code of frontpage.html.twig

TWIG
        {% set collection_path = page.find(path).collection('content') %}
        {% for module in collection_path %}               
          <div class="section">
              <div class="row">
                {% for module in collection_path %}
                  {% include '/modular/one_' ~ path|slice(13,path|length -14 ) ~ '.html.twig' %} 
                  {{module.content}}
                {% endfor %} 
              </div>
          </div>
        {% endfor %}      

Path variable contains the name of folder(ex. /components/_certificates ).

The final target is to show all modules, which we have in frontpage.md header.

10 years ago

And set your home page to the /components page.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1368 9 years ago
Archive · by Muut Archive, 9 years ago
2 942 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1125 9 years ago