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

Variable to determine list view or page detail view

Started by Muut Archive 11 years ago · 1 replies · 257 views
11 years ago

Is there a way in Grav/Twig to know you're looking at a blog post in a list. (In order to show different content in teaser than in detail page - eg. show pictures/media only on detail page, not on list page)

11 years ago

Well you have a few options. You can use a different twig template to render the item in the list and on it's own. Then in each template you can render things differently, or add a css class or something, to display things differently via css alone.

You could pass a variable into the twig include that tells the template if it's a list or a detailed view.

Alternatively you could have a header setting on the page with a 'summary or headline' or something that you use on the list view, then simply show the full content on the details view.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1984 9 years ago
Archive · by Muut Archive, 9 years ago
2 1338 9 years ago
Archive · by Muut Archive, 9 years ago
2 4539 9 years ago
Archive · by Muut Archive, 9 years ago
1 3392 9 years ago
Archive · by Muut Archive, 9 years ago
3 1487 9 years ago