Quote:
Originally Posted by Dirk2718
I put some tags on the book. One of these tags can identify the books like the custom column "extradir" from above. Is this the right code in single mode:
Code:
{tags:contains('ExtraDir', 'DirName/', '')}{author_sort}/{title} - {authors}
|
The template is very close to right. The problem: you are mixing single function mode and template program mode. You never use quotes around parameters in single function mode, but you always use them in template program mode.
In single function mode the template should be:
Code:
{tags:contains(ExtraDir,DirName/,)}{author_sort}/{title} - {authors}
In template program mode the template should be:
Code:
{tags:'contains($, 'ExtraDir', 'DirName/', '')'}{author_sort}/{title} - {authors}
Also note that the pattern used by "contains" is a case-insensitive regular expression. It is not doing an exact match, but is instead looking for the string ExtraDir anywhere inside a tag. For example, the pattern will match the tag "SomeXtraDirt". This may or may not be a problem.
If it is a (potential) problem, then use the following template. It must be in template program mode because a comma is being used as a parameter, something that cannot be done in single function mode.
Code:
{tags:'in_list($, ',', '^allbooks$', 'DirName/', '')'}{author_sort}/{title} - {authors}
The "in_list" function compares tag by tag instead of on all the tags as one value. Adding the anchors "^" (force start at beginning of string) and "$" (force finish at end of string) to the pattern ensures that the entire tag must be matched.
Adding "^" and "$" in contains will not work if there is nore than one tag, because all the tags are checked as a single value. Example: assume the tags for a book are "Fiction, Thriller, ExtraDir". The pattern is compared against all three at once, not just the last one, so "^ExtraDir$" will match nothing.