Hi,
I would like to extend the text block with a select field with which you can determine the text color.
With the Blueprint this works very well - but with the Template / Snippet I am not sure if this is a good solution.
Maybe an experienced Kirby user can take a look at it?
content.yml
extends: blocks/text
fields:
text_color:
extends: fields/colors
label: Text color
An if statement doesn’t (necessarily) need an else statement. In my example above, we first define $text. If the condition is true, $text gets redefined (whereas you set your condition first and inside that condition define $text.
You can also use str_replace instead of preg_replace: