Textarea formatting with ->kt() breaks mark-up when link included

Hey guys,
I have a setup where each project has different sub-pages for content types like video, image and text. Now I encountered a problem, when I insert links into my textarea in the backend and output my text formatted with ->kt() it breaks the output. It somehow strips the whole surrounding div away.
Attached a screenshot of how I output my text, I don’t think the error lies there as it works perfectly when no link included.

Thank you for any hint
Ben

39

What else is there in your text file? Any other custom Kirbytags?

The Starterkit homepage, for example, contains lots of link that are rendered fine.

What is the output you get?

BTW. It is not recommended to use PHP short tags <?. Use the echo shorttag <?= instead if echoing something, and use <?php in all other cases.

This is the content from the backend:

test asdad asfaw as (link: http://google.de text: Fairytale)

It renders the content up to the link, but not into the div in the template file, but one level higher. I’m using ->kt() with links in other parts of the site and it’s working fine.

Thanks for the hint with the short-tags, I actually had it that way, I was just trying around to find the error source.

Thank you
Ben

I’d have to see your complete template file, maybe there is an issue with your code, in any way I can’t reproduce this in a fresh Starterkit.

Could you test this in a Starterkit as well, please?

I also can’t reproduce in a fresh starter kit, but I also didn’t start setting up the same project structure yet.
This is the snippet outputting the projects:

The problem is that you are wrapping everything within an anker tag, so you end up with an anker tag within an anker tag.

Ahhh! That makes sense, thank you!!

On a side note:

$projectSlide->intendedTemplate()

returns a string, no need to add an empty string to cast to string.

Also, in template files, it is preferable (i.e. more semantic) to use alternative syntax instead of the curly braces (just saying).