Customised sort in Admin section

Author Message

paul bolger

Tuesday 26 June 2007 4:31:49 pm

A have a folder full of Calendar events and would like to customise the the sorting in the Admin section so that the objects are sorted by one of the object attributes, the start date. I've overridden children.tpl and I've found this bit of the template:

{let sort_fields=hash( 6, 'Class identifier'|i18n( 'design/admin/node/view/full' ),
                       7, 'Class name'|i18n( 'design/admin/node/view/full' ),
                       5, 'Depth'|i18n( 'design/admin/node/view/full' ),
                       3, 'Modified'|i18n( 'design/admin/node/view/full' ),
                       9, 'Name'|i18n( 'design/admin/node/view/full' ),
                       8, 'Priority'|i18n( 'design/admin/node/view/full' ),
                       2, 'Published'|i18n( 'design/admin/node/view/full' ),
                       4, 'Section'|i18n( 'design/admin/node/view/full' ) )
    title='You can not set the sorting method for the current location because you do not have permissions to edit the current item.'|i18n( 'design/admin/node/view/full' )
    disabled=' disabled="disabled"' }

Is there an easy way to add sorting options?

Paul Bolger

Greg McAvoy-Jensen

Tuesday 26 June 2007 7:48:34 pm

Paul,

One way would be to use the fetch function (http://ez.no/doc/ez_publish/technical_manual/3_9/reference/modules/content/fetch_functions/list):

fetch( 'content', 'list',
 hash( 'parent_node_id',            parent_node_id,
     [ 'sort_by',                   sort_by,                   ]

Perhaps something like this would be a start?

{def $pauls_list=fetch( 'content',         'list',
	hash(	'parent_node_id',     $node.node_id,
		'sort_by',		array( 'attribute', 1, 'pauls_class/start_date')	) )}


{foreach $pauls_list as $children}

	{node_view_gui content_node=$children view="line"}

{/foreach}

Replace "pauls_class" with the class of objects being sorted, and "start_date" with the identifier of "start date", if necessary.

Granite Horizon, Certified Developer of eZ Publish Web Solutions
Provider of the SaaS Solution Granite Horizon In The Cloud | http://granitehorizon.com/cloud
http://granitehorizon.com | +1 916 647 6350 | California USA | @granitegreg
Blog: http://granitehorizon.com/blog

paul bolger

Tuesday 26 June 2007 10:02:17 pm

Thanks Greg, but...

I could do it pretty easily in a display (external node) template, but those admin templates are hellishly complicated! By the looks of things you should be able to add options by adding entries to the hash table above, but I don't know the syntax for adding an attribute, and I'm not sure if it needs to be added somewhere else as well to work.

Paul Bolger

André R.

Wednesday 27 June 2007 1:09:15 am

If you add a custom entry there I'm afraid you have to hack ezcontentobjecttreenode.php to make it work.

Specifically the functions createSortingSQLStrings and sortFieldName.
From the last one you can see what is currently supported:

            case 1:
                return 'path';
            case 2:
                return 'published';
            case 3:
                return 'modified';
            case 4:
                return 'section';
            case 5:
                return 'depth';
            case 6:
                return 'class_identifier';
            case 7:
                return 'class_name';
            case 8:
                return 'priority';
            case 9:
                return 'name';
            case 10:
                return 'modified_subnode';

So I would rather recommend to override children.tpl to override the sorting.

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

paul bolger

Wednesday 27 June 2007 10:45:09 pm

......So I would rather recommend to override children.tpl to override the sorting.

Thanks Andre. I just wanted to check that there isn't an easy way before hoeing into the template.

BTW - is there a way to get these forums to show you the post you are replying to rather than the original question?

Paul Bolger

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

Main resources:

Total runtime0.8624 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 587.9375152.6250
Module start 'layout' 0.00540.0029 740.562539.4453
Module start 'content' 0.00830.8526 780.0078624.6094
Module end 'content' 0.86100.0014 1,404.617216.1563
Script end 0.8623  1,420.7734 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4069160.0002
Check MTime0.00170.1957160.0001
Mysql Total
Database connection0.00090.098710.0009
Mysqli_queries0.798992.6365650.0123
Looping result0.00070.0841630.0000
Template Total0.831296.420.4156
Template load0.00230.272020.0012
Template processing0.828896.113320.4144
Template load and register function0.00010.008610.0001
states
state_id_array0.00110.122410.0011
state_identifier_array0.00090.101520.0004
Override
Cache load0.00190.2228310.0001
Sytem overhead
Fetch class attribute can translate value0.00060.074530.0002
Fetch class attribute name0.00160.188480.0002
XML
Image XML parsing0.00170.193430.0006
class_abstraction
Instantiating content class attribute0.00000.0022100.0000
General
dbfile0.00120.1362310.0000
String conversion0.00000.000840.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
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/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: 27
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs