Define sortOrder
#1
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!
Reply
#2
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.
Reply
#3
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?
Reply
#4
(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?
OSMC Skinner      |    The OSMC Skin for Kodi v20 Nexus (native 16:9, 21:9 and 4:3 skin, special cinemascope/CIH version available)      |     GitHub: https://github.com/Ch1llb0/skin.osmc
Reply
#5
Container.SortOrder has the current Sort Order
Reply
#6
(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.
OSMC Skinner      |    The OSMC Skin for Kodi v20 Nexus (native 16:9, 21:9 and 4:3 skin, special cinemascope/CIH version available)      |     GitHub: https://github.com/Ch1llb0/skin.osmc
Reply
#7
@Chillbo 
I'm guessing you want https://codedocs.xyz/xbmc/xbmc/group__py...b136025f40
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
Debug Log (wiki) | Troubleshooting (wiki)Add-ons
Reply
#8
(2020-06-20, 16:01)anxdpanic Wrote: @Chillbo 
I'm guessing you want https://codedocs.xyz/xbmc/xbmc/group__py...b136025f40
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.
OSMC Skinner      |    The OSMC Skin for Kodi v20 Nexus (native 16:9, 21:9 and 4:3 skin, special cinemascope/CIH version available)      |     GitHub: https://github.com/Ch1llb0/skin.osmc
Reply

Logout Mark Read Team Forum Stats Members Help
Define sortOrder0