Page 1 of 1

LISE sort by item-alias?

Posted: Tue Oct 29, 2019 2:06 pm
by tbremer
Hello,

I want to sort the output of LISE by the item-alias.

In the module-help, something like "item_alias" is not listed as a valid orderby-column. And in fact, an orderby with "item_alias" has no effect :-)

My workaround is to define a custom textfield, which could be the target for an orderby. Works, but far away from being perfect and a confusing thing for my backend-users.

Is there a way to prevent the using of the extra custom-field and to sort directly by the item_alias?

Thanks.

Re: LISE sort by item-alias?

Posted: Tue Oct 29, 2019 9:19 pm
by Dr.CSS
Can you explain how you do it with the custom_field..?

Re: LISE sort by item-alias?

Posted: Tue Oct 29, 2019 9:33 pm
by DIGI3
You could sort the array before outputting instead of specifying it as a tag parameter. You'd likely need to make a UDT/plugin to do the sorting with the alias as the key.

If it's not a huge amount of data, you could also do it via javascript on the frontend. Just give each div the alias as a data-value or class then sort it on load. Not ideal if you're doing pagination though.

Re: LISE sort by item-alias?

Posted: Tue Oct 29, 2019 10:04 pm
by tbremer
Dr.CSS wrote:Can you explain how you do it with the custom_field..?
Yes, it is explained in the LISE-docs:
With fielddef values:
orderby='custom_[fielddef alias]'
For example: orderby='custom_year'

Re: LISE sort by item-alias?

Posted: Thu Oct 31, 2019 6:54 pm
by velden
A few notes:

Item-alias nor item_alias are valid properties of a lise item. 'alias' is though I don't know if it can be used for sorting. But of course you can try.

Sorting in the template like DIGI3 suggests could be a work-around as long as you don't use pagination.

If you're using a custom field it would be rather easy to create a UDT and use an event to auto-fill this field when the item is saved.

I'd start with trying 'alias'.