Hi there,
i just tried to create a collection with multiple category taxonomies in Twig
{% set collection = page.evaluate([{
'- @taxonomy.category': 'list',
'- @taxonomy.category': 'page'
}]) %}
But it seems, this just works, when it is set in the page header.
content:
items:
- @taxonomy.category: list
- @taxonomy.category: page
But the downside of this way is, that i would have to add this lines to every page....
Is there another way to get a "global" collection? The reason is, i want to have a navigation, which just gives me the links to pages with the categories "list" OR "page"
i think, i found a way to combine multiple collections in twig, but it feels a bit hacky... :) maybe anyone knows a nicer solution?
{% set collection = page.evaluate([{
'@taxonomy.category': 'list'
}])|merge(page.evaluate([{
'@taxonomy.category': 'page'
}])) %}
Collections are essentially just arrays of pages, so your 'hacky' way is really not that hacky, it's just using twigs merge filter to join two arrays. That's not a bad solution.
We really don't have a sophisticated query language for handling or relationships, this is something we would like to improve going forward, but for now your solutions is fine :)
I'm not sure how we implemented this, but I think that you can also do:
content:
items:
- @taxonomy.category: [list, page]
Not sure if it was using AND or OR. But its worth to try if it does the trick. :)
Also {% set pages =taxonomy.findTaxonomy({'category':['list','page']},'or') %} ?
Oh nice :) that would be great, i have to try this out :) thx!