Loading...
 
Skip to main content

History: PluginList sort control block

Source of version: 11 (current)

Copy to clipboard
            ! PluginList sort control block
__Setting Sort Mode__
Please be warned that sorting is normally based on string. If you are trying to sort by numbers, make sure all your numbers are of the same number of digits. Otherwise 2 will be larger than 12 if doing a string sort.
{CODE(colors="tiki")}
{sort mode="tracker_field_example_asc"}
{sort mode="tracker_field_example_desc"}
{CODE}or
{CODE(colors="tiki")}
{sort mode="title_asc"}
{CODE}

If you want to do a numeric sort (such that 12 is larger then 2, use the following instead:
{CODE(colors="tiki")}
{sort mode="tracker_field_ticketNumber_nasc"}
{sort mode="tracker_field_ticketNumber_ndesc"}
{CODE} or often
{CODE(colors="tiki")}
{sort mode="modification_date_ndesc"}
{CODE}
In the example above modification_date is used as the sort parameter - the list of other generic parameters that might be used to 'sort' and are available from Unified search are shown ((Search and List from Unified Index|here)).

__Starting with ((Tiki27))__: If you want to sort using two fields, separate them with a comma:
{CODE(colors="tiki")}
{sort mode="tracker_field_ticketCustomerName_text_asc,tracker_field_ticketNumber_nasc"}
{CODE}
In the example above we sort using ticketCustomerName in alphabetic order and for each value of ticketCustomerName we sort the ticketNumber in numeric ascending order.

There is also a way to simulate random results when showing a short list. This is of course not compatible with pagination. You have to specify a list of sort modes on irrelevant fields to choose randomly from, for example:
{CODE(wrap="1" colors="tiki")}{sort mode="randommode" modes="title_asc,tracker_field_example_asc,tracker_field_ticketNumber_nasc, modification_date_nasc"}
{CODE}(Note, opposite directions will be added automatically)

You can further select the results that are going to be return by using return_only, for example:
{CODE(wrap="1" colors="tiki")}{sort mode="tracker_field_ticketNumber_nasc" return_only="2,1,3"}
{CODE}will return only the 2nd, 1st and 3rd result, in that order.

__Starting with ((Tiki19|19.1))__ you can use scripted sort orders on Elasticsearch, as described [https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-sort.html#_script_based_sorting|here] for example:
{CODE(wrap="1" colors="tiki")}{sort mode="script" source="Math.abs(new Date().getTime() - doc['date'].date.getMillis() )" order="asc"}
{CODE} which sorts items by nearest to the current date/time.

!!All the LIST Plugin control blocks
{toc pagename="PluginList"}