Index: Slim/Utils/Prefs.pm =================================================================== --- Slim/Utils/Prefs.pm (revision 17367) +++ Slim/Utils/Prefs.pm (working copy) @@ -214,6 +214,7 @@ 'timeFormat' => q(|%I:%M %p), 'showArtist' => 0, 'showYear' => 0, + 'sortAlbumsByYear' => 0, 'guessFileFormats' => [ '(ARTIST - ALBUM) TRACKNUM - TITLE', '/ARTIST/ALBUM/TRACKNUM - TITLE', Index: Slim/Schema/ResultSet/Contributor.pm =================================================================== --- Slim/Schema/ResultSet/Contributor.pm (revision 17367) +++ Slim/Schema/ResultSet/Contributor.pm (working copy) @@ -7,6 +7,31 @@ use Slim::Utils::Prefs; +our $prefs = preferences('server'); + +our @albumSortRules = ( + # 0: No special sorting + "concat('0', album.titlesort), album.disc", + + # 1: Sort by year ascending, unset years last + "CASE album.year " . + " WHEN 0 THEN 9999" . + " ELSE album.year " . + "END, concat('0', album.titlesort), album.disc", + + # 2: Sort by year ascending, unset years first + "album.year, concat('0', album.titlesort), album.disc", + + # 3: Sort by year descending, unset years last + "album.year DESC, concat('0', album.titlesort), album.disc", + + # 4: Sort by year ascending, unset years first + "CASE album.year " . + " WHEN 0 THEN 9999" . + " ELSE album.year " . + "END DESC, concat('0', album.titlesort), album.disc" +); + sub pageBarResults { my $self = shift; @@ -111,8 +136,9 @@ $sort = $rs->fixupSortKeys($sort); } else { - - $sort = "concat('0', album.titlesort), album.disc"; + + my $sortByYear = $prefs->get('sortAlbumsByYear') || 0; + $sort = $albumSortRules[$sortByYear] || $albumSortRules[0]; } my $attr = { Index: Slim/Web/Settings/Server/UserInterface.pm =================================================================== --- Slim/Web/Settings/Server/UserInterface.pm (revision 17367) +++ Slim/Web/Settings/Server/UserInterface.pm (working copy) @@ -25,7 +25,7 @@ } sub prefs { - return ($prefs, qw(skin itemsPerPage refreshRate thumbSize longdateFormat shortdateFormat timeFormat showArtist showYear titleFormatWeb)); + return ($prefs, qw(skin itemsPerPage refreshRate thumbSize longdateFormat shortdateFormat timeFormat showArtist showYear sortAlbumsByYear titleFormatWeb)); } sub handler { Index: HTML/EN/settings/server/interface.html =================================================================== --- HTML/EN/settings/server/interface.html (revision 17367) +++ HTML/EN/settings/server/interface.html (working copy) @@ -30,6 +30,18 @@ [% END %] + + [% WRAPPER settingGroup title="SETUP_SORTALBUMSBYYEAR" desc="SETUP_SORTALBUMSBYYEAR_DESC" %] + + [% END %] [% END %] [% WRAPPER setting title="SETUP_TITLEFORMAT" desc="SETUP_GROUP_TITLEFORMATS_DESC" %] Index: strings.txt =================================================================== --- strings.txt (revision 17367) +++ strings.txt (working copy) @@ -4435,6 +4435,21 @@ NO Du kan velge å vise årstallet et album ble gitt ut når du viser albumlisten eller albumomslag. Når valget er påskrudd vil årstallet vises sammen med tittelen til albumet. ZH_CN 您可以选择通过浏览专辑或浏览专辑图象时是否一同显示专辑的年份。当您选择一同显示时,年份信息将显示在专辑标题旁边。 +SETUP_SORTALBUMSBYYEAR + EN Sort Albums in Artist lists by year + +SETUP_SORTALBUMSBYYEAR_DESC + EN You may choose to sort the albums by year when displayed within the artists list. Artist menu will be sorted by the year associated with that album. The order of sorting can be configured to be ascending or descended, with albums without years first or last. When disabled, the Albums listed from an Artist menu will be sorted alphabetic order. + +SETUP_SORTALBUMSBYYEAR_1 + EN Sort by year ascending, unset years last +SETUP_SORTALBUMSBYYEAR_2 + EN Sort by year ascending, unset years first +SETUP_SORTALBUMSBYYEAR_3 + EN Sort by year descending, unset years last +SETUP_SORTALBUMSBYYEAR_4 + EN Sort by year descending, unset years first + SETUP_SHOWARTIST DA Vis kunstner ved album DE Interpreten mit Alben anzeigen Index: Slim/Control/Queries.pm =================================================================== --- Slim/Control/Queries.pm (revision 17367) +++ Slim/Control/Queries.pm (working copy) @@ -41,6 +41,7 @@ use Slim::Utils::Log; use Slim::Utils::Unicode; use Slim::Utils::Prefs; +use Slim::Schema::ResultSet::Contributor; { if ($^O =~ /Win32/) { @@ -218,6 +219,20 @@ $where->{'contributorAlbums.contributor'} = $contributorID; push @{$attr->{'join'}}, 'contributorAlbums'; $attr->{'distinct'} = 1; + + # If no other specific sort has been specified, order the albums + # by year according to the player settings. + if (!$sort) + { + my $sortByYear = $Slim::Schema::ResultSet::Contributor::prefs->get('sortAlbumsByYear') || 0; + my $sort = $Slim::Schema::ResultSet::Contributor::albumSortRules[$sortByYear] || + $Slim::Schema::ResultSet::Contributor::albumSortRules[0]; + $attr->{'order_by'} = $sort; + + # Fix up the sort key to use the 'me' name, rather than 'album' + # table name which was used by the contributor album sort code. + $attr->{'order_by'} =~ s/album\./me./g; + } } }