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

How to hide content before === delimiter in article view?

Started by Dima 2 years ago · 13 replies · 359 views
2 years ago

I need to hide the summary content (everything before the === delimiter) when viewing a full article in Grav CMS. I only want to display the main content that comes after ===. What's the correct way to implement this?

Thank you in advance for your help!

2 years ago

Does page.summary return anything? Sounds like you don't have a summary 🤔

2 years ago

Summary works well in Blog List.
Cache is cleared regularly 🙂.

2 years ago

So what does page.summary|length say on the item page?

2 years ago

If you're talking about what's between the --- in the blog_item.en.md file, it looks like this:
summary: { }

2 years ago

That's the summary config, but what's the actual summary length?

2 years ago

Where exactly can I check the actual summary length? In which file or section should I look?
In /user/config/site.yaml it is written like this:

YAML
summary:
  enabled: true
  format: short
  size: 300
  delimiter: '==='
2 years ago

In blog-item.html.twig add:

TWIG
{{ dump(page.summary) }}
{{ dump(page.summary|length) }}

Or is it {% ... %} 🤔

2 years ago

Hi @Dima and @Karmalakas

I have just tested the recipe on my own installation and it works perfectly. Several things can happen here...

  • On the Blog page, where the entries are listed, a summary can be displayed even if it is not defined in your markdown file.
  • The code in blog-item.html.twig may be wrapped in a block that another file overwrites.
  • One other thing that escapes me 😅

I would make sure you have created the summary in the .md file and review the templates that are involved in the view. Surely the error must be in there!

1 reply
2 years ago

Good question:) Gantry Helium. But the content is placed in “Page Content”.

Suggested topics

Topic Participants Replies Views Activity
General · by Andy Miller, 2 days ago
0 64 2 days ago
General · by Veehem, 3 days ago
0 107 3 days ago
General · by milkboy, 4 days ago
0 110 4 days ago
General · by ian russell, 2 weeks ago
2 203 1 week ago
General · by pamtbaau, 1 month ago
2 459 2 weeks ago