sort draft list by classname

Author Message

Andreas Adelsberger

Thursday 31 May 2007 5:36:56 am

hi there!

i fetch a list of all drafts using

{let draft_list=fetch('content','draft_version_list',hash(limit,$page_limit,offset,$view_parameters.offset))}

how can i sort them for example by classname?

thanx for your help.

greetz andy

---------------------------------------
Styleflasher New Media OG
Websites. Games/Multimedia.

Andreas Adelsberger

Thursday 31 May 2007 11:13:57 am

ok, i found it out now myself.

you need the following extension:
http://ez.no/community/contribs/template_plugins/arraysortoperator

basically you have to

loop through $drafts_list
fill a new array with a string starting with the attribute you want to sort, followed by a separator, followed by the next attribute etc..

now you have a simple array where you can use your sort method.

afterwards turn the array using "explode" back into a assoziative array using "hash".

here is my code:

def $sorted_draft_array=array()}
{foreach $draft_list as $k => $v}

 {set $sorted_draft_array=$sorted_draft_array|append(concat(
 		$v.contentobject.class_name,
 		'--',
 		$v.version_name,
 		'--',
 		$v.contentobject.section_id,
 		'--',
 		$v.version,
 		'--',
 		$v.initial_language.name,
 		'--',
 		$v.modified,
 		'--',
 		$v.contentobject.id,
 		'--',
 		$v.id,
 		'--',
 		$v.contentobject.content_class.identifier,
 		'--',
 		$v.contentobject.content_class.name,
 		'--',
 		$v.initial_language.locale
 		)
 		)}


{/foreach}
{set $sorted_draft_array=$sorted_draft_array|sort('string')}

{def $narr=array()}
{set $draft_list=array()}
{foreach $sorted_draft_array as $itm}
	{set $narr=$itm|explode('--')}
	{set $draft_list=$draft_list|append(
						hash(	
						'contentobject',
										hash(
												'class_name'	,$narr.0,
												'section_id'	,$narr.2,
												'id'			,$narr.6,
												'content_class'	,hash(
																		'identifier',$narr.8,
																		'name',$narr.9
																		),
											),
						'version_name',$narr.1,
						
						'version',$narr.3,
						'initial_language',hash(
												'name',$narr.4,
												'locale',$narr.10
												),
						'modified',$narr.5,
						'id',$narr.7
						)
									)
	}
	
{/foreach}

i hope it helps!

---------------------------------------
Styleflasher New Media OG
Websites. Games/Multimedia.

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 22:32:49
Script start
Timing: Jan 18 2025 22:32:49
Module start 'layout'
Timing: Jan 18 2025 22:32:49
Module start 'content'
Timing: Jan 18 2025 22:32:49
Module end 'content'
Timing: Jan 18 2025 22:32:49
Script end

Main resources:

Total runtime0.6865 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.0089 587.9063152.6250
Module start 'layout' 0.00890.0035 740.531339.4453
Module start 'content' 0.01240.6725 779.9766495.5938
Module end 'content' 0.68490.0015 1,275.570312.1641
Script end 0.6864  1,287.7344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.5552160.0002
Check MTime0.00140.1970160.0001
Mysql Total
Database connection0.00130.189210.0013
Mysqli_queries0.629791.7347520.0121
Looping result0.00050.0706500.0000
Template Total0.648494.420.3242
Template load0.00210.299320.0010
Template processing0.646394.146720.3232
Template load and register function0.00020.026410.0002
states
state_id_array0.00130.183110.0013
state_identifier_array0.00230.339420.0012
Override
Cache load0.00170.2479230.0001
Sytem overhead
Fetch class attribute can translate value0.00090.131610.0009
Fetch class attribute name0.00120.169230.0004
XML
Image XML parsing0.00230.333410.0023
class_abstraction
Instantiating content class attribute0.00000.001540.0000
General
dbfile0.00260.3849160.0002
String conversion0.00000.001440.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
6content/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
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs