Include partial view with a complex collection:
{% include 'partials/article-main.html.twig' with {'page': #here goes condition} %}
How can i choose all pages, that has a field named main_article
in the headers/Frontmatter set to true?
It is not possible to use Collection for search a specific attribute in page, so you need to get a Collection (eg for all pages), create a for
loop to check if main_article
is available in a page and decide what to do with that page.
If doing that, you can't get an array of the pages which have main_article
attribute because removing element in a Twig array is painful. Twig is a template engine anyway.
So if you want to do in a better way and have ease in maintenance, you can build a custom plugin, do everything you need in the plugin with PHP and deliver the final array of pages to Twig.