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

How to list pages from a specific folder in a template blueprint

Started by Muut Archive 10 years ago · 3 replies · 422 views
10 years ago

I'm sure this is really simple but I can't find reference other than here on how to list the pages of a specified folder using the data-options@ function for a template's blueprint.

I can get list all pages using the '@data-options': '\Grav\Common\Page\Pages::parents' example but with various guesses like Pages::children(/pathtofolder) etc. have had no luck.

10 years ago

You can do something like this in your template; the answer is collections

TWIG
    <div class="row small-up-1 medium-up-3 large-up-4">
        {% for child in page.children.order('date', 'desc').ofType('classified') %}
        <div class="column">
            <div class="allout small classified">
                {% set showcase_image = child.media.images|first.resize(270,270).url %}

                <a href="{{ child.url }}">
                    <h4 class="float-center">{{ child.menu }} <br /> {{ child.header.price }} &euro;</h4>
                    {% if showcase_image %}
                    <img alt="{{ child.title }}" src="{{ showcase_image }}" class="float-center" />
                    {% endif %}
                </a>
            </div>
        </div>
        {% endfor %}
    </div>

You can also define collection in your headers as said in the doc.

10 years ago

Thanks for your reply. However, I'm talking about the YAML blueprint used to create a form for users to create content in the admin section.

10 years ago

So the doc is (almost) straightforward as it includes only yaml samples. Or I totally misunderstood your point (in this case, sorry)

Or is it more this that you expect ?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1350 9 years ago
Archive · by Muut Archive, 9 years ago
2 935 9 years ago
Archive · by Muut Archive, 9 years ago
2 4061 9 years ago
Archive · by Muut Archive, 9 years ago
1 2948 9 years ago
Archive · by Muut Archive, 9 years ago
3 1119 9 years ago