Kirby tags in writer field?

I’ve created a custom kirby tag to add special formatting to certain strings, and I would like to use this tag in a writer field. Apparently this isn’t working, it prints the text literally, even when doing $page->writerfield()->kirbytext(). Is there any way to enable kirby tags in writer fields? Or do I have to resort to textarea?

What type of html does this kirbytag contain?

Pretty simple, just some generic inline tags:

<?php

Kirby::plugin('example/tag', [
	'tags' => [
		'example' => [
			'html' => function($tag) {
				$class = in_array(strtolower($tag->value()), ['value1', 'value2', 'value3']) ? strtolower($tag->value) : 'example';
				return '<span class="example"><b>custom</b>tag\_<b class="'.$class.'">'.$tag->value().'</b></span>';
			}
		]
	]
]);

If I write (example: test) it prints exactly this in the output instead of converting it to the appropriate HTML.

Works for me, but of course you have to use the kirbytext() field method to render tags.

Hm, this is very strange. I’m using this in my custom FAQ block for the accordion summary and details fields (as seen on Block factory: Creating your own blocks collection | Kirby CMS) and it works on the summary field but not on the details field.

This is the accordion blueprint:

name: "Accordion"
icon: bars
fields:
	summary:
		label: Summary
		type: writer
		marks:
			- bold
			- italic
		placeholder: Add summary …
		nodes:
			- paragraph
	details:
		label: Detail
		type: writer
		marks:
			- link
			- bold
			- italic
			- strike
			- email
		nodes:
			- bulletList
			- orderedList

This is my template:

<?php
$faq_sections = $page->inhalt()->toBlocks();
if($faq_sections->isNotEmpty()):
?>
	<?php foreach($faq_sections as $section): ?>
		<h3><?= $section->heading() ?></h3>
		<?php
			$faq_items = $section->faq()->toBlocks();
			if($faq_items->isNotEmpty()):
		?>
		<dl>
			<?php foreach($faq_items as $item): ?>
			<dt><?= $item->summary()->kirbytextinline() ?></dt>
			<dd><?= $item->details()->kirybtext() ?></dd>
			<?php endforeach; ?>
		</dl>
		<?php endif; ?>
	<?php endforeach; ?>
<?php endif; ?>

(and for the records: it doesn’t matter if I use the kirbytext() or kirbytextinline() methods)

There is a difference between those two fields, the allowed nodes, I’m pretty sure that’s causing it.

Nope, I added a “paragraph” node, I removed the entire node property, nothing changes (of course I changed the content an re-saved the page every time).

Wait a minute! I changed it to the alias kt() or kti() methods and then it works. What gives? :thinking:

Edit: Aww dammit! It was a stupid typo!!! (you can even see it in my post above if you look closely) :man_facepalming: