Forums / Setup & design / A link how to sort on a page
Jens Kultima
Friday 06 April 2007 2:56:42 am
Hi!
There are many ways of sorting nodes in Exponential. 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