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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Listing Page Twig Template Not Working

Started by Noelle 8 years ago · 3 replies · 613 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 Pedro M, 2 months ago
4 196 2 months ago
Themes & Styling · by Ian, 2 months ago
3 92 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 454 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 47 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 126 3 months ago