Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Best approach for injecting pages in pages

admin first-time

Started by Artem Artemov 9 years ago · 0 replies · 915 views
9 years ago

(or displaying projects)

Hey there, so I am working through creating my first template - idea is a cinematography or video portfolio.

I have created a new page "type" called projects in the admin with specific fields. Under the page directory projects, I have children pages of each project item.

On my projects page I have a list of all the projects, and when I click on a project I am able to see the full view.

I was looking to put that "list" of projects into the default.html.twig file and was wondering if this was the best approach.

TWIG
{% set options = {
        items: {
            '@page.children': '/projects'
        },
        'limit': 5,
        'order': {
            'by': 'date',
            'dir': 'desc'
        }
    } %}
    {% set projects = page.collection( options ) %}

    <section class="project-items">
        {% for p in projects %}
            <div class="project-single">
                <div class="project-media">
                    <div class="project-image">

It works totally as expected, however seems a little backwards of thinking. Would love some input!

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by themetman, 6 days ago
1 104 3 days ago
Themes & Styling · by AH, 3 weeks ago
1 224 3 days ago
Themes & Styling · by Bruno, 4 years ago
6 1388 3 days ago
Themes & Styling · by TomW, 3 weeks ago
2 227 5 days ago
Themes & Styling · by FrViPofm, 2 months ago
4 687 2 months ago