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

Blog Summary on Modular Page

Started by Muut Archive 10 years ago · 2 replies · 829 views
10 years ago

I know is has come up before but the posts I have read left me still unsure if this is possible or not.

I'm using the Antimatter blog skeleton and have added a modular home page in which I would like to display a summary of the first three blog posts with images. Is it possible to build a twig template that will achieve this within a modular page, if so how is the best way to go about it.

Also I'm wondering the best way to include a standard header image into the blog template. I have a customised 'showcase' template, could I just 'include' this into the blog temple?

Sorry if these are basic questions but any help would be much appreciated

10 years ago

Your modular child page can simply have this in its header:

YAML
content:
    items: 
        '@page': '/blog'
    order:
        by: date
        dir: desc
    limit: 10
    pagination: true

and in the corresponding Twig file you iterate the collection:

TWIG
{% for p in page.collection %}
<h2>{{ p.title }}</h2>
{{ p.summary }}
{% endfor %} 

This solves the first thing.

You can include any Twig template in another one, using {% include 'twig_filename' %}

10 years ago

Great, fantastic works perfectly, thank you!

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1370 9 years ago
Archive · by Muut Archive, 9 years ago
2 943 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1127 9 years ago