Kodi Community Forum
Define sortOrder - Printable Version

Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
--- Thread: Define sortOrder (/showthread.php?tid=354867)



Define sortOrder - codingPF - 2020-05-31

Hi,

i am struggeling to find the proper place to define the sort order for a video list in my plugin. Can someone point me into the right direction?
I have already added different sort methods which can be choosen in the context menu. Now i would like to enable sortOrder (ASC/DESC) via settings as well.

Scenario:
A video list can be sorted by airDate.
The default is ASC but i would like to enable the user to choose DESC as his prefered sort order.


Thanks!


RE: Define sortOrder - learningit - 2020-06-01

You can just let the user select the type and order of display sort from the skin. You'll probably get into conflict issues having both an add-on setting and a skin setting. Not sure which will prevail.


RE: Define sortOrder - codingPF - 2020-06-09

I found the option to toggle the sort by using build in function Container.SetSortDirection. But this toggles the option. With getting the current state it is not really doing the trick...
Is the any option to get the current sort order?


RE: Define sortOrder - Chillbo - 2020-06-20

(2020-06-01, 17:40)learningit Wrote: You can just let the user select the type and order of display sort from the skin. You'll probably get into conflict issues having both an add-on setting and a skin setting. Not sure which will prevail.

The issue is that, if you set the sort key 'Date' with addon content (as a user), the default sort order is simply wrong. It then shows the content ordered by date, ascending. But for most use cases I can think of, it would be logical to sort by date descending (from newest to oldest) by default and not the other way round. This also means that the newest content is always at the end of a page and on the next page, the content right after that would be at the end of the list again. This doesn't make any sense.

If this cannot be changed entirely in Kodi, is there a way for addons to set whether the sort order of a sort key should be ascending or descending by default, @learningit?


RE: Define sortOrder - learningit - 2020-06-20

Container.SortOrder has the current Sort Order


RE: Define sortOrder - Chillbo - 2020-06-20

(2020-06-20, 03:24)learningit Wrote: Container.SortOrder has the current Sort Order

But can an addon define what the default sort order should be for, let's say 'Date', for all its pages? That it can be manually changed for each page via the skin toggles, I know. But the default way of sorting the date sort key just doesn't make much sense, so it would have to be changed manually every time by users.


RE: Define sortOrder - anxdpanic - 2020-06-20

@Chillbo 
I'm guessing you want https://codedocs.xyz/xbmc/xbmc/group__python__xbmcplugin.html#ga85b3bff796fd644fb28f87b136025f40
The first one added is the default for that listing.
Code:
xbmcplugin.addSortMethod(<addon_handle_here>, xbmcplugin.SORT_METHOD_DATE)
.
edit: sorry for the noise, I mis-read Smile


RE: Define sortOrder - Chillbo - 2020-07-04

(2020-06-20, 16:01)anxdpanic Wrote: @Chillbo 
I'm guessing you want https://codedocs.xyz/xbmc/xbmc/group__python__xbmcplugin.html#ga85b3bff796fd644fb28f87b136025f40
The first one added is the default for that listing.
Code:
xbmcplugin.addSortMethod(<addon_handle_here>, xbmcplugin.SORT_METHOD_DATE)
.
edit: sorry for the noise, I mis-read Smile

Any way though to set the sort order for all addon pages for a specific sort key (Date)? Addons like YouTube solve this by using a NoSort which it populates with the reverse order of 'Date'. But that's not a nice way to do it.


This forum uses Lukasz Tkacz MyBB addons.