getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.31k stars 168 forks source link

Custom KirbyTag always first in html output of textarea #4283

Closed caplod closed 2 years ago

caplod commented 2 years ago

Description

A custom KirbyTag always gets rendered first in html output of a textarea field no matter where I put it.

Expected behavior
The tag gets rendered in the correct position in html output

To reproduce

  1. My Plugin
    
    <?php
    Kirby::plugin('your/plugin', [
    'tags' => [
    'button' => [
      'attr' => [
        'text'
      ],
      'html' => function($tag) {
        if (empty($tag->lang) === false) {
          $tag->value = Url::to($tag->value, $tag->lang);
        }
        return snippet('components/link', ['url' => $tag->value, 'text' => $tag->text], false);
      }
    ]
    ]
    ]);
2. Snippet (components/link)
````php
<a class="uppercase flex items-center text-teal" href="<?= $url ?>">
  <?= $text ?>
  <div class="ml-2">
    <?php snippet('svg/arrow') ?>
  </div>
</a>
  1. Screenshot of backend kirbytext

  2. Template <?= $page->team_text()->kt() ?>

  3. Wrong order in HTML output

    <a class="uppercase flex items-center text-teal" href="team">
    go to team  <div class="ml-2">
    <svg class="fill-current  w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11.289 7.056">
    ...
    </svg>
    </div>
    </a>
    <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. </p>
    <p>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>

Your setup

Kirby Version
3.6.5

afbora commented 2 years ago

Could you try following line that using snippet function with third param as true please?

return snippet('components/link', ['url' => $tag->value, 'text' => $tag->text], true);
caplod commented 2 years ago

Thanks for the tip, Yeah I got the last parameter wrong. Now its working fine!