Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

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

Started by Pascal Mahlberg 9 years ago · 1 replies · 967 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 peterparker08, 2 hours ago
0 9 2 hours ago
General · by Andy Miller, 4 days ago
0 85 4 days ago
General · by lynbor, 4 weeks ago
3 423 2 weeks ago
General · by lynbor, 3 weeks ago
7 539 2 weeks ago
General · by Harry, 2 weeks ago
0 149 2 weeks ago