IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Help with Sorting in Panels UI
potatotron
post Apr 6 2007, 21:46
Post #1





Group: Members
Posts: 5
Joined: 11-June 06
Member No.: 31717



I've searched extensively on this issue, and I've found a few things, but I lack the coding ability to put those bits of code together into something that'll work.

I want to be able to sort my Panels UI playlists according to three criteria:
  • In sorting artist names, leading instances of 'The' are ignored
  • Within an artist, albums are sorted by year
  • Compilation albums are grouped together, preferably at the top or bottom

Would anyone mind writing out the code that would make this work?

Thanks in advance.
Go to the top of the page
+Quote Post
TheBlackCat
post Apr 7 2007, 03:46
Post #2





Group: Members
Posts: 21
Joined: 20-February 07
Member No.: 40775



1. Use the CWB Hooks $cwb_removethe command to remove "The" and "A" (the word, not the letter) from the beginning of a string. For instance $cwb_removethe(%title%) removes "The" or "A" from the beginning of the title if present. If you just want "The" removed but not "A", you can use $cwb_ltrim from the same component. Just do: $cwb_ltrim(%title%,The) You can also use it if you want more than just The and A. In include "An" as well, by doing $cwb_ltrim(%title%,The,A,An).

2. Make a new grouping criteria where the "Primary Sort" field is $if2([$meta(date)],%album%) and the secondary sort is %album% Have "Group by Sort" checked. This will cause it to sort first by the year, if it is present, then by the album title. It will also group by the same criteria (I assume all tracks in an album have the same year). So it will sort by year, then for albums that are in the same year it will sort by the title of the album. If there is not date field it will just sort by the title. Alternatively you could use $if2([$meta(date)],9999) as the primary sort. This will sort by the year if it is present, but if it isn't it will put all of those albums at the very end. you could use 0000 instead of 9999 to put all albums without a year at the very beginning instead, or some arbitrary year to put them in the middle. Otherwise it will behave the same.

3. This depends on hoy you tag compilation albums. For instance if all your compilation albums have an Album Artist that is different from their regular Artist you could use

CODE
$if([%track artist%],(Compilation),%album%)


In this code if the %artist% and %album artist% fields are different %track artist% will exist and thus [%track artist%] will return a string (which $if counts as "true"). In this case it will group it into a fixed (Compilation) group no matter what other properties it has, since "(" has a higher sort priority than letters and numbers if I remember correctly. If the %artist% and %album artist% fields are the same, in the case where there is only one artist on an album, then %track artist% is blank. That makes [%track artist%] return a false, causing the program to group by the %album% field (you can make that whatever you want). Note that if there is no %album artist% field, %album artist% simply displays the %artist% field and thus %track artist% will not exist. Same is true if there is no %artist% field but there is an %album artist% field (probably a rare situation). You can modify that initial test however you want, just as long as it either returns true or false depending on whether it is a compilation or not.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 21st October 2014 - 05:21