Displaying field value in plain text and replacing spaces with a -?


In my blog im using the category title for css styling. My code is

class="c-<?= $article->category()->lower() ?>"

And this is fine for most of the categories, except one which is made up of two words and has a special character. The category is called ‘Priča Se’. Does a field method maybe exist which will output that category title as ‘prica-se’?

Other option is that I can always update my structure for categories to include additional text for css classes…

I think you are looking for Str::slug() | Kirby CMS :slight_smile:


There is also a field method for that

 class="c-<?= $article->category()->slug() ?>"
1 Like

I was ready to look into this option but texnixe’s method worked! Thank you both.