Forums / Setup & design / Is there a way to sort related_contentobject_array on node names?

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

eZ debug

Timing: Jan 31 2025 03:52:01
Script start
Timing: Jan 31 2025 03:52:01
Module start 'content'
Timing: Jan 31 2025 03:52:01
Module end 'content'
Timing: Jan 31 2025 03:52:01
Script end

Main resources:

Total runtime0.1671 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 589.4766180.7969
Module start 'content' 0.00590.0065 770.273493.9766
Module end 'content' 0.01230.1547 864.2500522.9531
Script end 0.1670  1,387.2031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00342.0303200.0002
Check MTime0.00130.7789200.0001
Mysql Total
Database connection0.00070.439910.0007
Mysqli_queries0.122473.24561410.0009
Looping result0.00130.80051390.0000
Template Total0.154392.310.1543
Template load0.00100.608010.0010
Template processing0.153291.712710.1532
Override
Cache load0.00080.463910.0008
Sytem overhead
Fetch class attribute can translate value0.00060.352410.0006
XML
Image XML parsing0.00020.143710.0002
General
dbfile0.00653.8609200.0003
String conversion0.00000.004930.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs