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 →

Get a collection of all "CHILDREN" but only with a special "TAG"

Started by Pascal Mahlberg 9 years ago · 1 replies · 1073 views
9 years ago

I would like to show a collection of all "CHILDREN" pages with a special "TAG"

For now i use this collection:

TWIG
{% set items = page.collection({'items':{'@self.children': '{{item.title}}'}, 'limit': '6','order': {'by': 'default', 'dir': 'asc'}}) %}
      {% for item in items %}
        <a href='{{item.url}}' class='{{item.title|lower|replace({'ä': "ae", 'ö': "oe", 'ü': "ue", 'ß': "ss", '.': "-"})}} cell'>{{item.title}}
        <img src="/images/inspiration/kachel-nav/{{item.title|lower|replace({'ä': "ae", 'ö': "oe", 'ü': "ue", 'ß': "ss"})}}.jpg" alt="">
        </a>
      {% endfor %}

But here i would like to filter these Items only whit the tag: "top"

So i would like to combine @self.children & @taxonomy but i think it will not work.

Any suggestions? Is this possible?

👍 1
9 years ago

I do a similar thing to find all 'featured' posts, here is my Twig:

TWIG
{% for post in taxonomy.findTaxonomy({'tag': "featured"}) %}
 {% include 'partials/blog_item.html.twig' with {'page':post, 'truncate':true} %}
{% endfor %}

And here is another method I use:

TWIG
{% for child in collection %}
  {% if "featured" in child.taxonomy['tag'] %}
    {% include 'partials/blog_item.html.twig' with {'blog':page, 'page':child, 'truncate':true} %}
  {% endif %}
{% endfor %}

Maybe the above might be of help?

last edited 10/25/17 by Paul Hibbitts

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 23 hours ago
2 40 16 hours ago
General · by Hanns Mattes, 1 week ago
0 121 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago