Forums / Developer / fetch distinct contentobject
Fabien Scantamburlo
Friday 16 April 2010 4:08:59 am
Hi,
I need to fetch a list of eZContentObjectTreeNode
fetch( content, list, hash( parent_node_id, $node_id, ... ) )
But, I need to fetch only distinct eZContentObject. So, the main_node_only parameter remove too much nodes inside the subtree. So I can't filter the list after the request cause I need to build a page system and to set the OFFSET and LIMIT parameters.
I looking at the extended_attribute_filter, but it doesn't seem to allow a DISCTINCT clause.
Is there anyone know how to do this ?
Thanks in advance,
Fabien.
Nicolas Pastorino
Friday 16 April 2010 4:30:04 am
Hello Fabien,
Well, the main_node_only parameter should do what you are willing to do. What do you exactly mean by : "So, the main_node_only parameter remove too much nodes inside the subtree."
Cheers,
-- Nicolas Pastorino Director Community - eZ Member of the Community Project Board eZ Publish Community on twitter: http://twitter.com/ezcommunity t : http://twitter.com/jeanvoye G+ : http://plus.tl/jeanvoye
Friday 16 April 2010 5:23:13 am
Hi Nicolas,
The main_node_only parameter only retrieve the main location (or main node, as you want).The main_node_only parameter doesn't retrieve the content objects which the main node is outside the sub-tree.
I need to fetch all content objects in the sub-tree. But without the main_node_only parameter the query probably fetch same content object many times (cause of different locations in the sub-tree).
I need: one content object → one node.
Thanks for you help Nicolas.
Monday 19 April 2010 12:26:22 am
Ok, got it.
I'd go for a custom fetch function here, overriding the content/list one (to preserve the many useful parameters ), going as follows :
Hope it helps !Cheers,
[1] : http://ez.no/doc/ez_publish/technical_manual/4_x/reference/modules/content/fetch_functions/list
Monday 19 April 2010 9:34:54 am
It works fine!
Good job!
Thanks,
Monday 19 April 2010 10:52:55 am
{def $beer_count = fetch( 'beer', 'count', hash( 'from', 'Fabien', 'to', 'Nicolas', 'where', 'at the ez conference in Berlin' ))} {$beer_count|attribute( 'show', 1, false() )} {* Displays : beer_count (1) *}
:)
The eZ Conference : http://share.ez.no/blogs/ez/ez-conference-2010-in-berlin-next-june
See you there !Cheers,
Tuesday 20 April 2010 1:17:05 am
OK Nicolas,
Hope to see you next time for a beer! :)