Forums / Setup & design / Customised sort in Admin section

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