Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Listing Page Twig Template Not Working

Started by Noelle 9 years ago · 3 replies · 763 views
9 years ago

I am attempting to make a listing page for my portfolio of work.

To do this, I used the Grav admin to create a page called "Portfolio." I then created two subpages under it.

After that, I created a twig partial template with the following code:

TWIG
{% extends 'partials/base.html.twig' %}

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

    {{ page.content }}
{% endblock %}

For some reason, though, no listing is displayed and only the Portfolio page's content diaplays.

Did I miss a step? Thanks so much to anyone who can give me some insigth!

last edited 03/23/18 by Noelle
9 years ago

Have you also created the collection in your 'Portfolio' page front-matter like so? -

YAML
content:
  items: '@self.children'
  order:
    by: date
    dir: desc
👍 1
9 years ago

@gnat:
content:
items: '@self.children'
order:
by: date
dir: desc

Aaaah! This solved it. Thank you. For some misguided reason, I thought when you built a collection in the admin, this was done automatically. Good to know! Thank you so much.

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by FrViPofm, 2 weeks ago
4 395 6 days ago
Themes & Styling · by johan thomas, 5 years ago
1 753 2 weeks ago
Themes & Styling · by stuart young, 2 months ago
3 609 2 months ago
Themes & Styling · by Sebadamus, 2 months ago
5 623 2 months ago
Themes & Styling · by martynfoster735, 2 months ago
1 595 2 months ago