We just transitioned from K2 to K3. I noticed that in some content files in textarea-elements there are strings like {{start}} or {{end}} contained which in K2 would be replaced by the value of the actual field in the blueprint - as it seems, simply by calling $page->beschreibung()->kirbytext() in the template.
However, in K3 the strings are displayed unchanged in the frontend view - i.e. the front end text reads literally
…{{start}}…
Can some one please help me which function achieved the placeholder replacement in K2 and how I can get the same result in K3?
However, I find it quite concerning, that there seems to be a regression in many parts from K2 to K3 with this as the latest example: K2 filters provide a $kirbytext argument which gives access to the $page object, the corresponding K3 hook doesn’t.
I didn’t say that, I said I had to look into this, because I don’t know everything. Turns out, you have access to the $this object, with is the Kirby instance, which gives you access to the $site object and the current page, e.g.
What you have in your brackets is the key. You return Str::template() with the arguments, i.e. the text and your replacements as array of key /value pairs.
The {{ }} is in my case part of the field $text in function ($text). And sometime there are more than one {{ }} in the field $text.
And the replacements are in the config file and not in the fields of the current page.
The config file /site/config/config.php results in:
<?php
return [ // Make sure to only use a single "return" statement in this file !!!
// other config settings
// https://k2.getkirby.com/docs/developer-guide/kirbytext/filters
'kirbytext.snippets' => [
'email' => 'bastian@getkirby.com',
'lorem' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
],
// other config settings
];
The plugin file /site/plugins/textsnippets/index.php looks like: