Fetch contentlists and distinct

Author Message

Børge Warvik

Thursday 21 August 2008 1:25:35 pm

Hi,

I've made a class (Inquiry) that contains an attribute called "Assigned To". It's of datatype "Object relation", Selection method is dropdownlist, and default selected items is "Editors"

Any instance of that class may be placed in 1 to 5 differen folders using the "Add location"-functionality.

On a summarypage, I try to list all instances of that class for the current user. This is done by the code below. When placing the instance in different folders, each of those instances gets a new "node_id", but keeps the same "contentobject_id". The fetch below want't select distinct on "contentobject_id" only "node_id".

Is there a way around this?


{def $user=fetch( 'user', 'current_user' ) }

{def $relatedobjects=fetch(
	'content', 'list',
	hash(
		'parent_node_id', 2,
		'class_filter_type', 'include',
		'class_filter_array', array( 'inquiry' ),
		'depth', 10,
		'attribute_filter',
		array(
			array(
				'inquiry/assigned_to',
				'=',
				$user.contentobject_id
			)
		),
		'sort_by',
		array(
			'attribute',
			true(),
			'inquiry/status'
		)
	)
)}


Børge Warvik

Thursday 21 August 2008 2:01:23 pm

Problem solved.


{def $referencerelatedobjects=array()}
{def $uniquerelatedobjects=array()}
{foreach $relatedobjects as $object}
	{if $referencerelatedobjects|contains($object.contentobject_id)|not()}
		{set $uniquerelatedobjects=append($uniquerelatedobjects, $object)}
		{set $referencerelatedobjects=append($referencerelatedobjects, $object.contentobject_id)*}
	{/if}
{/foreach}


Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.