Accessing content of a field in markdown

Hi, I would like to reference the content of a field (the phone number in this case) in markdown, for consistency, so I have the phone number just stored in one place and reference it wherever I want do display it.

Directly in the template I do it like this <?= page('impressum')->phone() ?>

Question: is it possible to access this same field for the content editor using markdown?

The best way to do that would be a custom Kirbytag, maybe (phone:). So the user would just enter this into the markdown field, and in your tag logic, you would return the centrally stored phone number.

Kirby::plugin('your/plugin', [
    'tags' => [
        'phone' => [
            'html' => function($tag) {
                if (($page = page('impressum')) && $page->phone()->isNotEmpty()) {
                   return $page->phone();
                }
                return '';
            }
        ]
    ]
]);
1 Like

Thanks for this very quick solution! It works flawlessly! :heart: