Split text field and convert to markdown

Hi everyone!
Im trying to split a markdown panel field by the # and later render each split as a markdown again. Is this posible.
Here a faux code to explain what I want to do.
I tried with the structure field but it wasn’t what I need because I can’t drag and drop images.

Thanks in advance!

<?php foreach($topic->text()->split('#') as $item): ?>
  <p><?php echo $item->kirbytext()?></p>
  <?php endforeach ?>

The reason that does not work is that you are calling the kirbytext() method on a string. What you can do is this:

<?php foreach($topic->text()->split('#') as $item): ?>
  <p><?php echo kirbytext($item)?></p>
<?php endforeach ?>

You may also think about using other characters (or rather multiple characters, e.g. ++++) as delimiters as the hashmark # is used to create headlines in markdown.

1 Like