Collection Index via {model}
Posted: 03 Dec 2018, 08:14

If you use {collection} to organize movies by movie collection, then you will find that many movie collections don't show in order if you sort the {ny} filename alphabetically.
If you process all entries of a collection in one go, then you can use the {model} binding to compute the movie number within a given collection.
Code: Select all
{model.findAll{ it.collection == collection }.sort{ it.d }.findIndexOf{ it.id == id } + 1}
- Access all bindings for all matches via {model}
- Find all matches where the collection matches the collection of the movie we're currently formatting
- Sort by release date
- Find index of movie that matches the movie we're currently formatting
- Plus 1 because index starts at 0
e.g.
Code: Select all
The Girl With The Dragon Tattoo (2009)
The Girl Who Played With Fire (2009)
The Girl Who Kicked The Hornet's Nest (2009)
Code: Select all
{collection}/{model.findAll{ it.collection == collection }.sort{ it.d }.findIndexOf{ it.id == id } + 1}. {plex.name}
Code: Select all
The Millennium Collection/1. The Girl with the Dragon Tattoo (2009)
The Millennium Collection/2. The Girl Who Played with Fire (2009)
The Millennium Collection/3. The Girl Who Kicked the Hornet's Nest (2009)