Share » Forums » Developer » Fetch objects having children with a...

Fetch objects having children with a particular attribute

Fetch objects having children with a particular attribute

Monday 23 October 2006 12:14:28 pm - 4 replies

Author Message

Łukasz Serwatka

Tuesday 24 October 2006 12:14:28 am

Hi,

Use tree fetch with attribute_filter ( http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/tree ), then in loop display parent names.

{def $nodes=fetch( content, tree, ... )}

{foreach $nodes as $node }
    {$node.parent.name}
{/foreach}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Andrey Astakhov

Tuesday 24 October 2006 4:57:09 am

Thank you, Lukasz.
From my understanding in this case tree fetch will return child objects matching given criteria but not parent objects. Is it correct?

Łukasz Serwatka

Tuesday 24 October 2006 5:10:00 am

Yes, that is correct. You can also try with extended attribute filtering but that is more complex way. There is an example in doc.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Andrey Astakhov

Tuesday 24 October 2006 5:24:42 am

Extended attribute filter is still difficult for me. I'm trying to do it on template level.

Ok, if it's correct then it is not what i need.

How do you think which approach is better:

1) Get all child objects ($childs) filtered by a criteria attribute1 = 'a' . Then get a list of parent objects for this child objects $childs. Is it possible?

or

2) Get all parent objects ($parents). Then iterate through $parents getting childs for each item and filtering by criteria attribute1 = 'a'.

?

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

36 542 Users on board!

Forums menu