Multiple taxonomy collection with pagination, limit, and order in twig?

In a twig template, how can I request a collection with pagination, limit, and order using “findTaxonomy”? I need to create a list of the latest posts in certain categories. The following experiment does not work:

{% set blog_collection = taxonomy.findTaxonomy({'category':['Music', 'Film']}, 'or').visible().published().setParams({'limit': 5, 'pagination': true}).order('date', 'desc') %}

Alternately, is there some other way to accomplish the same thing? I did try the usual way but it seems to only allow one category. That is, I can’t say {’@taxonomy.category’: ‘Film, Music’} or {’@taxonomy.category’: [‘Film’, ‘Music’]} in the following:

{% set blog_options = { items: {'@taxonomy.category': 'Film'}, 'limit': 3, 'order': {'by': 'date', 'dir': 'desc'}, 'pagination': false } %}
{% set blog_collection = page.collection(blog_options) %}

Note that I cannot use frontmatter in this case, as there are other parts of this complex page with different needs. Plus I really want to know how this works in twig.

I tried posting this question but somehow it got archived so I’m trying again.

I think findTaxonomy will fetch only the published page, so you can remove .published from the filter. Also, it seems like you are checking for .visible which means it will only displays page that are displayed in the menu.

You could try adding the parameters and filter one by one and see if it works.

Hope it helps

In order to make taxonomy collections filters like .published() .nonPublished() etc., for example I needed to list the future published articles for logged in admins.

\system\src\Grav\Common\Taxonomy.php, around line 56

  public function addTaxonomy(PageInterface $page, $page_taxonomy = null)
  {
      if (!$page_taxonomy) {
          $page_taxonomy = $page->taxonomy();
      }

/*        
      if (empty($page_taxonomy) || !$page->published()) {
          return;
      } 
*/

      if (empty($page_taxonomy)) {
          return;
      }

      /** @var Config $config */
      $config = $this->grav['config'];
      if ($config->get('site.taxonomies')) {
          foreach ((array)$config->get('site.taxonomies') as $taxonomy) {
              if (isset($page_taxonomy[$taxonomy])) {
                  foreach ((array)$page_taxonomy[$taxonomy] as $item) {
                      $this->taxonomy_map[$taxonomy][(string)$item][$page->path()] = ['slug' => $page->slug()];
                  }
              }
          }
      }
  }