Sort grandchildren

Author Message

Softriva .com

Tuesday 02 January 2007 11:46:54 pm

Hello,

I have a listing as

M2 (node #301)
--S1 (node #401)
--S3 (node #402)
--S2 (node #403)

M1(node #302)
--S1 (node #401)
--S3 (node #402)
--S2 (node #403)

I do fetching as

{def $cM=fetch(content,list, hash('parent_node_id', 59,'sort_by',array( 'priority', true() )))}

When I list them they appear as

M1 (node #302)
--S1 (node #401)
--S3 (node #402)
--S2 (node #403)

M2(node #301)
--S1 (node #401)
--S3 (node #402)
--S2 (node #403)

Note that only M1 and M2 are sorted based on priority but not S1, S2 and S3.

I use the following code to list them

{foreach $cMs as $cM}
	{$cM.name|wash}
		{foreach $cM.children as $child}
			<a href={$child.url_alias|ezurl()}>{$child.name|wash}</a>
		{/foreach}
{/foreach}

How can I sort S1, S2 and S3?

André R.

Wednesday 03 January 2007 3:35:34 am

$some_node.children is not sorted, and as you will see from the debug output the children is fetched when you call $some_node.children (the ezcontentobjecttreenode object have several dynamicly fetched methods).

So instead I suggest you do something like this:

{def $cMs=fetch(content,list, hash('parent_node_id', 59,'sort_by',array( 'priority', true() )))
      $subM=false()}
{foreach $cMs as $cM}
        {$cM.name|wash}
        {if $cM.is_container}
            {set $subM=fetch(content,list, hash('parent_node_id', $cM.node_id,'sort_by',array( 'priority', true() )))}
                {foreach $subM as $child}
                        <a href={$child.url_alias|ezurl()}>{$child.name|wash}</a>
                {/foreach}
        {/if}
{/foreach}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Softriva .com

Thursday 04 January 2007 2:39:36 am

Thank you, worked perfect.

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 20 2025 16:46:59
Script start
Timing: Jan 20 2025 16:46:59
Module start 'layout'
Timing: Jan 20 2025 16:46:59
Module start 'content'
Timing: Jan 20 2025 16:47:00
Module end 'content'
Timing: Jan 20 2025 16:47:00
Script end

Main resources:

Total runtime1.1527 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.0043 587.8906151.1953
Module start 'layout' 0.00440.0021 739.085936.6172
Module start 'content' 0.00641.1451 775.7031564.9063
Module end 'content' 1.15160.0011 1,340.609411.8750
Script end 1.1527  1,352.4844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.2615160.0002
Check MTime0.00130.1139160.0001
Mysql Total
Database connection0.00040.037110.0004
Mysqli_queries1.109596.2504570.0195
Looping result0.00050.0443550.0000
Template Total1.123997.520.5620
Template load0.00190.167120.0010
Template processing1.122097.332920.5610
Template load and register function0.00020.019310.0002
states
state_id_array0.00150.126710.0015
state_identifier_array0.00060.052620.0003
Override
Cache load0.00160.1425350.0000
Sytem overhead
Fetch class attribute can translate value0.00060.054320.0003
Fetch class attribute name0.00110.091740.0003
XML
Image XML parsing0.00060.049720.0003
class_abstraction
Instantiating content class attribute0.00000.000840.0000
General
dbfile0.00070.0588170.0000
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
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.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: 22
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs