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.

eZ debug

Timing: Jan 18 2025 15:05:46
Script start
Timing: Jan 18 2025 15:05:46
Module start 'layout'
Timing: Jan 18 2025 15:05:46
Module start 'content'
Timing: Jan 18 2025 15:05:47
Module end 'content'
Timing: Jan 18 2025 15:05:47
Script end

Main resources:

Total runtime0.7032 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 588.0313152.6406
Module start 'layout' 0.00570.0029 740.671939.4766
Module start 'content' 0.00850.6933 780.1484460.4297
Module end 'content' 0.70180.0014 1,240.57818.1484
Script end 0.7032  1,248.7266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.4548160.0002
Check MTime0.00130.1878160.0001
Mysql Total
Database connection0.00120.166710.0012
Mysqli_queries0.662194.1531520.0127
Looping result0.00040.0572500.0000
Template Total0.672495.620.3362
Template load0.00170.242420.0009
Template processing0.670795.373720.3354
Template load and register function0.00010.013110.0001
states
state_id_array0.00120.176310.0012
state_identifier_array0.00170.247220.0009
Override
Cache load0.00140.1964140.0001
Sytem overhead
Fetch class attribute can translate value0.00050.074110.0005
Fetch class attribute name0.00080.113230.0003
XML
Image XML parsing0.00050.077110.0005
class_abstraction
Instantiating content class attribute0.00000.001540.0000
General
dbfile0.00090.1284160.0001
String conversion0.00010.018140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 10
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs