firelex
firelex

Reputation: 135

Extbase: get number of child objects

I have following model: "Shelf" and "Book", being in 1:n relation.

In the listing of shelves I need the number of books on each shelf. How can I get that?

In the database table "Shelf" there is a column "books" having the number I need. But in the model "books" is an ObjectStorage, so I cannot get the count of child object over this property.

In my list view I have

<f:for each="{shelves}" as="shelf">
...
{shelf.books.0.title} //<-- this works perfectly returning title of first book
{shelf.books.count} //<-- this produces no output

Upvotes: 2

Views: 283

Answers (1)

firelex
firelex

Reputation: 135

I found it myself: <f:count>{shelf.books}</f:count> is the solution

Upvotes: 3

Related Questions