Quote:
Originally Posted by ownedbycats
Don't remember about specific tags in SFM. But this will list the first tag alphabetically and also get rid of an extra '-' when there's no tag.
{tags:sublist(0,1,&)| - |}
|
Quote:
Originally Posted by chrisric
Thanks ownedbycats.
Using {tags:sublist(0,1,&)| - |} produces the same result as {tags}
I searched "Reference for all built-in template language function" and found nothing specific to tags that might work. Of course, I have no idea if any of the other functions may work.
I guess I could save the file with {tags} and use an external script to rename the file. I'd prefer that being a last resort though.
|
Read up on the list functions. They all work on tags.
The separator for tags is a comma, not an ampersand. As said in
Using functions in templates - Single Function Mode (SFM), you enter a literal comma using \,
Code:
{tags:sublist(0,1,\,)}
The following template in
Template Program Mode (TPM), is easier to understand (for me at least):
Code:
{tags:'sublist($, 0, 1, ',')'| - |}
However, you appear to be asking to test for the existence of a particular tag. That can be done by embedding
General Program Mode (GPM) into TPM
Code:
{tags:'if '^xyz$' inlist $tags then 'xzy' fi'| - |}
If for some reason you don't want to embed GPM then this "pure" TPM template does it:
Code:
{tags:'in_list($, ',', '^xyz$', 'xyz', '')'| - |}