Low Search Orderby Relationship Field
Hi,
I have a low search plugin at my website which is listing the properties entries from the properties channel :
{exp:low_search:results
query="{segment_3}"
channel="properties"
orderby="property_size"
sort="asc"
collection="properties"}
I need to order the results by a custom field :
Custom Field Name:Timing
Custom Field Type: Relationships (to another channel Timing)
So, I am not sure how to order by this custom field as Its working fine with normal fields in the "Properties" channel but NOT with the relationship fields!!!
Thanks for your help!
Behzad
Replies
Low 21 Sep 2015 11:46
Like the native channel:entries tag, ordering by a Relationships field doesn't really make sense: what is the data you want to order the entries by? The related entry's title? A custom field in that related entry? What if you can select multiple entries?
If you really need to order by a custom value like that, you'll have to create an extension for LS to set the custom order yourself.
Behzad Noroozi Fotoohieh 21 Sep 2015 12:00
Hi :)
Thanks for your reply.
I attached the screenshot what I have in result page and let me explain it again.
I have a channel called "properties" inside it i have a custom field (relationship) to another channel called "years". So each property has a year from that channel.
in the search form I am listing all of them from their "year" channel and results works absolutely fine.
But in search:results page at the moment I only can order the properties by their title/size/description and all other fields that they are not relationship !?
so what I need to achieve is simple when you search anything the result always needs to be sorted and ordered by YEAR (ascending).
Thanks
Behzad
Low 21 Sep 2015 12:11
Yes, I understand. You want to list entries from the Properties channel ordered by Year, where Year is a related entry belonging to the Years channel.
In your case, ordering by a Relationships field might make sense, but in general it doesn't. With the Relationships field, you could select multiple entries, making the order ambiguous.
Anyway, if you want to order by year, you'll have to create a custom field in the Properties channel where you either enter the year (a Text Input field) or select the year from a list (Select Dropdown field). As with the native channel:entries tag, ordering by a Relationships field is not possible.
With LS at least, you could create an extension to make it possible.
Behzad Noroozi Fotoohieh 21 Sep 2015 12:23
Hi,
Thanks very much for your clarification and makes sense now.
Kind Regards
Behzad