A link how to sort on a page

Author Message

Jens Kultima

Friday 06 April 2007 2:56:42 am

Hi!

There are many ways of sorting nodes in eZ Publish. I have the following question I have not found an anwer to:

I have a folder with nodes of the same class contain data. I can use the following code to sort them:

{fetch( 'content', 'list', hash( 'parent_node_id', 42,

                                 'sort_by',        array( 'attribute', 

                                                          false(), 

                                                          'data_name' ) ) )}

My first question is: in whcih file should I put this code? In the folder.tpl-file?

My second questions is: is it possible to make the above code into a hyperlink so that users can choose how to sort by clicking on a link on my page?

Thank you,
Jens

Badii Bouteraa

Friday 06 April 2007 5:37:39 am

Hello!

I'm still a newbie in ez but I think that it will works like that

To classify the nodes you can put variables into the url and get them thanks to the $view_parameters function.

// template code

{def $var=false()}
{def $sorting='DESC'}

{if $view_parameters.sorting|eq('DESC')}
{set $var=true()}
{set $sorting='ASC'}
{else}
{set $var=false()}
{set $sorting='DESC'}
{/if}

{fetch( 'content', 'list', hash( 'parent_node_id', 42,
                                    'sort_by',
				     array( 'attribute', $var, 'data_name' )
			             ) )} 

// Link
<a href={concat($node.url_alias,"/(sorting)/",$sorting)|ezurl}>DESC</a>

Badi

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 00:38:03
Script start
Timing: Jan 31 2025 00:38:03
Module start 'layout'
Timing: Jan 31 2025 00:38:03
Module start 'content'
Timing: Jan 31 2025 00:38:04
Module end 'content'
Timing: Jan 31 2025 00:38:04
Script end

Main resources:

Total runtime1.0136 sec
Peak memory usage8,192.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.1328151.2109
Module start 'layout' 0.00560.0042 739.3438220.6875
Module start 'content' 0.00981.0031 960.03134,403.1172
Module end 'content' 1.01290.0006 5,363.14847.8516
Script end 1.0136  5,371.0000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.3599160.0002
Check MTime0.00130.1251160.0001
Mysql Total
Database connection0.00090.086410.0009
Mysqli_queries0.927091.4534540.0172
Looping result0.00050.0535520.0000
Template Total0.955294.220.4776
Template load0.00200.198320.0010
Template processing0.953194.037020.4766
Template load and register function0.00170.170610.0017
states
state_id_array0.00330.320710.0033
state_identifier_array0.00180.174020.0009
Override
Cache load0.00170.1666180.0001
Sytem overhead
Fetch class attribute can translate value0.00180.175620.0009
Fetch class attribute name0.00220.218030.0007
XML
Image XML parsing0.00190.191820.0010
class_abstraction
Instantiating content class attribute0.00000.001130.0000
General
dbfile0.00700.6932160.0004
String conversion0.00000.000940.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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/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
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: 13
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs