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.

Archive

Modular name in twig

Started by Muut Archive 9 years ago · 1 replies · 573 views
9 years ago

Please tell me how to get the name of a modular page template using twig? It is necessary to insert in the templates instead of the id.
Thanks!

9 years ago

You can find this twig variable using dump(). Open up modular.html.twig and add dump() like this:

TWIG
{% for module in page.collection() %}
        {{ dump(module) }}
         etc.
         etc.

You need to enable the debugger in admin/config/system, then load your modular page and you'll see the debugger bar along the bottom of the page. Click on messages, and you'll see something like this for each modular subpage:

TXT
Grav\Common\Page\Page {#167 #name: ...

If you click on this you'll see all the available twig variables for that subpage. One of them will be the template for that subpage.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1318 9 years ago
Archive · by Muut Archive, 9 years ago
2 915 9 years ago
Archive · by Muut Archive, 9 years ago
2 4024 9 years ago
Archive · by Muut Archive, 9 years ago
1 2900 9 years ago
Archive · by Muut Archive, 9 years ago
3 1082 9 years ago