Is there a way to sort related_contentobject_array on node names?

Author Message

Conor Murray

Wednesday 10 September 2003 9:29:40 am

I'm drawing a blank with this one... I want to use related content to generate links in alphabetic sequence, but because these values are contained within an array in a single node, I can't see any way of using fetch to sort them for me.

Here's the loop I'm using to output the links, without any formatting elements:

{let Linkholder=fetch(content,node,hash(node_id,496))}
{section loop=$Linkholder.object.related_contentobject_array}
{content_view_gui view=text_linked content_object=$:item}
{/section}
{/let}

This works fine, except the array appears to be sorted by node obect order, where I really want to sort in alphabetical sequence on the names of the related objects.

Has anyone got any suggestions please?

Language is a virus - William S Burroughs

Gunnstein Lye

Thursday 11 September 2003 5:07:17 am

This is not supported directly. You have a few options:

1. Create a template operator that takes $Linkholder.object.related_contentobject_array as an argument and returns a sorted list.

or
2. Modify the relatedContentObjectArray() function in kernel/classes/ezcontentobject.php so that it sorts the result by name. ("ORDER BY ezcontentobject.name" at the end of the SQL query should do the trick, I think.)

or
3. Create a template operator that takes an object as an argument and returns a sorted list of related objects. It's about the same as #2, but cleaner.

Conor Murray

Thursday 11 September 2003 5:39:01 am

Thanks Gunnstein,

I went with the quick, dirty fix (suggestion 2), as I doubt I will ever want to display this data in anything other than alphabetical sequence. The modification you suggested worked perfectly :-)

I'm currently trying to stick to using the default template operators as much as possible, but I can see that for some sites it will be necessary to create new operators. When I find the time I will write a few template operators of my own, but that won't be tomorrow!

Thanks again for your very useful and accurate reply :-)

Language is a virus - William S Burroughs

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 31 2025 05:30:46
Script start
Timing: Jan 31 2025 05:30:46
Module start 'layout'
Timing: Jan 31 2025 05:30:46
Module start 'content'
Timing: Jan 31 2025 05:30:48
Module end 'content'
Timing: Jan 31 2025 05:30:48
Script end

Main resources:

Total runtime1.1931 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0047 588.4219151.2422
Module start 'layout' 0.00470.0021 739.664136.6953
Module start 'content' 0.00681.1853 776.3594929.6875
Module end 'content' 1.19210.0010 1,706.046911.7813
Script end 1.1931  1,717.8281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2643160.0002
Check MTime0.00130.1054160.0001
Mysql Total
Database connection0.00090.071510.0009
Mysqli_queries1.126794.4322570.0198
Looping result0.00060.0530550.0000
Template Total1.160397.220.5801
Template load0.00260.217320.0013
Template processing1.157797.029520.5788
Template load and register function0.00160.133910.0016
states
state_id_array0.00160.134310.0016
state_identifier_array0.00170.141220.0008
Override
Cache load0.00210.1742250.0001
Sytem overhead
Fetch class attribute can translate value0.00090.072020.0004
Fetch class attribute name0.00300.250040.0007
XML
Image XML parsing0.01070.895120.0053
class_abstraction
Instantiating content class attribute0.00000.001240.0000
General
dbfile0.01040.8728160.0007
String conversion0.00000.000640.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
3content/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
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs