Output placeholder text as html

Hello everyone,

I have a page for users that can create input from frontend, after the succesfull input the user sees success page. It’s very similar to this cookbook: Creating pages from frontend | Kirby CMS (getkirby.com), it has same plugin etc.

Now I got a small Issue, I have a personalized message in “success page”. When in markdown, the message is shown correctly, in markdown it looks like this:

Thank you for your message, here is your personalized link: {{ meetlink }}

Output on success page looks like this:

Thank you for your message, here is your personalized link: https://example/12930712301293081

But I’d love to have a raw html message without markdown linking it. I tried to use this in template:

  <?= $page->text()->html(); ?>

it outputs:

Thank you for your message, here is your personalized link: {{ meetlink }}

As mentioned, i need the pure text. I know it sounds weird, but it’s neccessary in my user case :slight_smile:
Do anyone has an idea how to achieve this?

This maybe?

Hi @jimbobrjames

when I’m using

 <?= $page->text()->unhtml(); ?>

the result is the same output with only placeholder. Probably I’m using it wrong? :see_no_evil:

Its not a field method, Its one of Kirby’s internal helpers, used under the hood by kirby but you can lean on them if need to. Theres a whole bunch of useful stuff for manipulating strings and arrays etc. Full list here. Objects | Kirby CMS

You need to use it like this. This will render the markdown, giving you the link text you need and the strip the HTML from it, leaving behind the text INSIDE the link.

  <?php $stripped = Str::unhtml($page->text()->kt()): ?>

If you need to do this all over the place, you can make your own custom field method using it if you want, then you will be able to chain ->unhtml() onto it.

Once set up youll be able to use it like a regular feild method as you said above…

 <?= $page->text()->unhtml(); ?>
1 Like

Fantastic, thanks a lot - this indeed helped!

1 Like