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

Best approach for injecting pages in pages

admin first-time

Started by Artem Artemov 9 years ago · 0 replies · 617 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 Pedro M, 2 months ago
4 198 2 months ago
Themes & Styling · by Ian, 2 months ago
3 94 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 455 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 48 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 128 3 months ago