Editting tag separators

Hi there,

As you can see in this page : https://studiodailleurs.com/sos-homophobie
I listed tags about the project I’m talking about.

Is there anyway I could replace the commas by the typo I would like ?
These tags are called with php : <?= $page->tags()->html() ?>

It seems I have to edit the kirby core file.
Anyone has an advice ?

Thanks a lot !

A tags field contains a list of comma separated tags. Instead of printing them out like you do, you should create an array of tags first, then you can do with them whatever you like. See the docs: https://getkirby.com/docs/reference/panel/fields/tags#how-to-use-in-templates-snippets

I suggest you render them as a list or spans, then use CSS to add a separator.

The alternative would be to implode the resulting array:

<?= implode(' | ', $page->tags()->split(',') ?>
1 Like

Thanks for your answer,

In which file should I use this bit of code ?

In the same file where you now call $page->tags()->html()

1 Like

Hmm, if I place that code inside the same div as <?= $page->tags()->html() ?> the debug mode displays :confused:

Ok, I also tried the first solution you suggested.
In my php template project page I wrote :

<div class="tags-projet">
  <ul>
    <?php foreach ($page->tags()->split() as $tags): ?>
    <li><?= $tags ?></li>
    <?php endforeach ?>
  </ul>
</div>

Then in my CSS style sheet I specified :

li{
  display: inline;
}

I get this result :

So there’s no commas anymore (yay). But I still don’t get how to display a specific separator.

Ok I got my answer !

Adding :

li:after {
    content: " |";
}
li:last-child:after {
    content: "";
} 

solved the problem :slight_smile:

1 Like