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.

Support

Can I store modular content in something other than the page content?

Solved by Josh View solution

Started by Josh 5 years ago · 2 replies · 379 views
5 years ago

Is there anyway to store modular content is something other than 'content' in the yaml file? I want to fill a sidebar with modular content, but from the docs it becomes part of the page content and then gets rendered with the content.

TWIG
---
title: 'Here''s the latest news'
menu: Read
process:
    markdown: true
    twig: true
content:
    items: '@self.modular'
    order:
        by: default
        dir: asc
        custom:
            - find-specific
            - popular-posts
---

{% include 'partials/most-recent-posts.html.twig' %}

This gets rendered with {{ page.content }} in my template which is undesirable. What's the best way to store and render modular content separate from the page content? Thanks.

5 years ago

@skipper, It seems I often get confused lately... And unfortunately, I'm also getting confused by this question.

Please help the community help you by creating clear and succinct questions.

Is there anyway to store modular content is something other than ‘content’ in the yaml file?

  • What is: modular content?
    The markdown (= content) of a modular page (modular.md), or the end-result of a Twig template that combines the content (markdown) of several modules into a single HTML page?
  • What do you mean by: is something other than ‘content’ in the yaml file
    • What is "'content'"
    • Which yaml file? Or do you perhaps mean the frontmatter/header (which contains yaml) of the page?

but from the docs it becomes part of the page content and then gets rendered with the content.

Please clarify...

This gets rendered with {{ page.content }} in my template which is undesirable. What’s the best way to store and render modular content separate from the page content?

Please clarify...

In your snippet you are trying to include the result of a Twig template into the Markdown (content) of a modular page.

  • Why?
  • Shouldn't the Twig file for that modular page be changed?
    Or maybe create a new module for the modular, with its own Twig template that lists the "most-recent-posts?
  • What are you trying to achieve?

Please consider updating your initial post instead of creating a new reply.

last edited 11/17/21 by pamtbaau
5 years ago Solution

Thanks for steering me, and sorry for the confusing question. I think I figured it out. I think my problem was that page.find('/read').children was rendering pages AND modular pages. Doing a check for {% if not firstPost.modular() %} is weeding out the non-modular pages.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 53 9 hours ago
Support · by Anna, 3 days ago
2 59 12 hours ago
Support · by Justin Young, 13 hours ago
1 30 13 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 56 5 days ago