How to use variables from site.yml in panel textarea to later expand on front end?

Hi there,

For a project, I’ve created global fields like “maximum respond date,” “average shipping date,” and “fee,” etc. in site.yml

Now, I need to build out the terms and conditions, as well as some legal pages, and reference these variables throughout the text.

In the legal.yml file, I have a text area.

My question is: how can I ensure that {{ site.shipping_date }} is populated with the actual value?

For example, here’s what my panel text looks like:

We are pleased to inform you that your order will be shipped by {{ site.shipping_date }}. Please ensure that you are available for delivery on or after this date. Thank you for choosing us!

However, I’m having trouble figuring out how to get it to display the actual value. I perfectly can see all the markup bold, italic, lists, etc… but not the actual Shipping_date or other variables.

In my legal.php file, I’m using, so it keeps the styling of the textarea:

<?= $page->text()->kt() ?>

Any insights would be greatly appreciated!

Thanks.

In a textarea field that you display in the template via ->kt() you could use a custom Kirbytag to achieve want you’re after.

Within your Kirbytag you can basically program whatever you want to happen.

You can use Str::template to replace those placeholders

Thank you both, after some experimentation, placeholders seems the way to go. I will experiment later with tags!

Thank you!

Thank you.
Good to know about kirbytags. However I will probably go with placeholders as it is easier to define in the panel. I have this client that wants to change basically everything themselves for those legal pages.

All the best.

Great! It might be interesting to know about i18n::template() too, in case the website needs to be multilingual!