Skip to content
Grav 2.0 is officially stable. Read the announcement →
Themes & Styling

Listing Page Twig Template Not Working

Started by Noelle 8 years ago · 3 replies · 663 views
8 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
8 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
8 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 Justin Young, 2 weeks ago
1 165 2 weeks ago
Themes & Styling · by Slebeig, 1 month ago
4 288 1 month ago
Themes & Styling · by Pedro M, 3 months ago
4 615 3 months ago
Themes & Styling · by Ian, 3 months ago
3 320 3 months ago
Themes & Styling · by Norbert, 2 years ago
11 745 4 months ago