This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » eZ Publish 5 Platform » How to get location children count in...

How to get location children count in a twig template?

How to get location children count in a twig template?

Sunday 10 February 2013 4:23:11 pm - 4 replies

Hello. Maybe because i still has the habits of tpl files, i'm wondering if is there any way to get the children count for a location from a twig template. 

It's it possible right now? if not, Would be a Twig Extension the right way to do it?


Monday 11 February 2013 10:16:57 am

Hi Carlos

Currently, the best out-of-the-box way to do this is to use a sub-controller since you'll need the LocationService to do so.

However I guess that exposing a little eZ Publish repository services would be nice at some point.

Maybe Damien can give you more hints ?

Monday 11 February 2013 11:55:23 am

Hi Carlos,

This is more or less the same issue as in Mathieu's recent post. For now, the sub-request is clearly the way to go. However, I personally feel that in some use cases that's a bit weird and I already wrote about this in the post about the Planet eZ That's why, I created an enhancement request for an alternative way of doing this. Feel free to comment the JIRA issue, if you like the idea or if you have any remark.


Modified on Monday 11 February 2013 11:59:45 am by Damien Pobel

Monday 11 February 2013 12:36:48 pm

Wow. but, before going to jira... it's me or does it sounds not easier than ezp4?. My first use case is the usual "if location has children do something else do something else"...

that seemed an easy task to me in ezp4...

Tuesday 12 February 2013 7:47:57 am

Hi Carlos,

This is the same thing with related objects. I've test a method with PreContentView class: just identify my contentType and load what i need (for my example was related objects) .. So on your template you have directly all you need happy.gif Emoticon




You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from