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

Module within Module

Started by Muut Archive 11 years ago · 2 replies · 487 views
11 years ago

Hi all,

For a single page project I would like to use a module in a module, but im not entirely sure if that will actually work out how I imagined.

The one page layout is working fine, consisting of 3 different modules shown on a modular page. Now the idea is to break down one of the modules in two separate modules.

Would this be possible with Grav?

11 years ago

I think you can achieve following with taxonomies. This is how i done it in SoraArticle theme (see sidebar, it's exactly as you requested, another modular layout):

TWIG
{% for module in page.collection({'items':{'@taxonomy.category': 'sidebar'},'order': {'by': 'default', 'dir': 'asc'}}) %}
   <h2 class="title">{{ module.title }}</h2>
    {{ module.content }}
{% endfor %}

Then in your .md file you have to specify taxonomy:

MD
taxonomy:
    category: sidebar

This way I loaded another modular layout for "sidebar" module. You can have as many different taxonomies as you want which allows basically to create unlimited modular layouts on the same page.

11 years ago

So simple.. can't believe i missed the option to use taxonomies! Thanks a lot!

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1352 9 years ago
Archive · by Muut Archive, 9 years ago
2 935 9 years ago
Archive · by Muut Archive, 9 years ago
2 4063 9 years ago
Archive · by Muut Archive, 9 years ago
1 2949 9 years ago
Archive · by Muut Archive, 9 years ago
3 1119 9 years ago