Php 如何使用两种ContentType筛选列表?

Php 如何使用两种ContentType筛选列表?,php,symfony,silex,bolt-cms,Php,Symfony,Silex,Bolt Cms,如何创建一个列表页面,其中结果基于两个ContentType上的过滤器 例如: books: name: Books singular_name: Book relations: authors: multiple: false categories: multiple: false authors: name: Authors singular_name: Author categories: name: Categories

如何创建一个列表页面,其中结果基于两个ContentType上的过滤器

例如:

books:
  name: Books
  singular_name: Book
  relations:
    authors:
      multiple: false
    categories:
      multiple: false

authors:
  name: Authors
  singular_name: Author

categories:
  name: Categories
  singular_name: Category
如何列出按作者和类别筛选的书籍

/books/(category\u slug)/(author\u slug)/

编辑 好的,我找到了路线的“解决方案”:

books:
  path: /books/{slug}/{author}
  _controller: Bolt\Controllers\Frontend::record
  contenttypeslug: categories
  author: all
然后我可以访问
/books/foo
/books/foo/bar
。 在模板中,我可以通过
app.request.attributes.get('author')
访问
author

现在的问题是如何通过这两种内容类型获取/过滤
书籍

编辑2 好吧,我在最后达到这个目的是为了过滤,不确定这是不是最好的方法,看起来不像:

{% set author_slug = app.request.attributes.get('author') %}
{% set books = category.related('books') %}
{% for book in books %}
    {% set author = book.related('authors')[0] %}
    {% if author_slug == author.slug or author_slug == 'all' %}
        My filtered book {{ book.title }}
    {% endif %}
{% endfor %}
这是最好的方法吗?