To render a list of Content items, for example, content in a folder, blog posts in a blog, and so on, you can use one of two methods:
List children with Query type¶
The following example shows how to render the children of a Folder.
First, in the content view configuration, add the following view for the Folder Content Type:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
controller defines which controller is used to render the view.
In this example, it is the default Query controller.
params define that you want to render the content by using the
Children Query type.
This Query type automatically finds the children of the current Content item.
The results of the query are placed in the
items variable, which you can use in templates.
Then, place the following template in
1 2 3
This template uses the
ibexa_render() Twig function
to render every child of the folder with the default template for the
List children in Content query Field¶
A Content query Field is a Field that defines a query. The following example shows how to use a Content query Field to render a Blog with its Blog Post children.
First, create a Blog Content Type that contains a Content query Field with the identifier
In the Field definition, select "Children" as the Query type.
content parameter that the Query type requires:
You can paginate the query results by checking the Enable pagination box and selecting a limit of results per page.
Select the Content Type you want to render (in this case, Blog Post) as Returned type.
Then, in the content view configuration, add the configuration under
1 2 3 4 5 6 7
match configuration matches both the Content Type and the identifier of the Content query Field.
Finally, in the template
templates/themes/<my_theme/content_query/blog_posts.html.twig, render all results of the query:
1 2 3