I’m trying to get KirbyText links to work so that each link gets a random number added to its class name. So that if there’s a text file with the text ”(mylink: # text: click here class: test)”, the resulting html link would include
class=“test99”
or a similar result. I’ve made a plugin based on the KirbyText link, which has this section:
But now I can’t figure the right way to add that random number to the class. Other than that the plugin functions as it should, as it is just a copy of the original, but as soon as I try to add $mynumber to the line
‘class’ => $tag->class,
it doesn’t work anymore. I’ve tried different ways, but with no success so far.
Be aware though, that nothing is truly random, and there are freak occurances where you may end up with the same class name on two elements. I would atleast raise the number to 1000. If it was me, i would uses the title rather than a number, converted to lowercase and spaces replaced with a dash. It means the CSS is more readable. if you add the page name + the link title together, then in the css it is obvous what page that link is one.
For some reason however, that doesn’t work. When I add the variable like that, the link isn’t recognized as a link anymore, the html page shows everything (the link, the text, etc.) as plain text.
It works now with the hardcoded word “testing”, but if I try to use either of the variables from the beginning there, either the link shows as plain text or nothing shows up.