Output as kirbytext

Hey folks,

ive the following problem. How can i get my variable boxtext shown in kirbytext?

<?php $boxen = array_slice($page->textboxen()->yaml(),0,3); ?>
<?php foreach($boxen as $box): ?>
	<div class="col-md-6">
		<h3><?php echo $box['boxtitel']; ?></h3>
		<p><?php echo $box['boxtext']; ?></p>
		<?php if (strlen($box['boxlink']) > 0) {
	 		echo '<p><br/><a href="' . $box['boxlink'] . '" class="btn btn-success">' . $box['boxbutton'] . '</a></p>';
<?php endforeach ?>

I dont get it :open_mouth:

Thanks guys!

Instead of the above using the kirbytext helper:

<?= kirbytext($box['boxtext']) ?>

Explanation: $box['boxtext'] is just a string, so you can’t call a field method on it. (Don’t use p tags when using kirbytext.)

Or use toStructure() instead of yaml() then you can just call the method like usual:

echo $box->boxtext()->kt();
1 Like

Thanks for your help!
Problem solved :slight_smile: