I am having trouble with tags. The basic idea of what I am trying to do is have a page that has all of its subpages listed. The problem is that I want the subpages names to have different css text styles depending on the kind of content they have. So I gave each subpage one of three styles through a tag field in the yml. Each subpage has then a tag that is let’s say styleone, styletwo or stylethree.
Now the tricky part. I tried to write if statements like so:
The problem I am encountering is “undefined variable: tag”. Why? But I guess my question is broader: would that even be the correct way of doing that? or am I better off trying to add a class through js? how would that work? I am a bit confused. Thanks for your help in advance!
I cleared the cache and everything seems to be linked correctly. If I replace “<?= $subpage->tag() ?>” with “styleone” it works, so somehow it doesn’t read the name correctly?
Note that you will get undesired results if users enter more than one value or a wrong value (typos). Since you can’t limit tags to certain options in Kirby 2, consider using a select field with fixed options instead.