Show all the existing tags

I need to show all the existing tags found across the different pages.
I’m using the code below but it repeats the tags if those are appearing more than one time.

Can I show a list of the existing tags without being repeated?

<?php foreach ($Page->children()->listed() as $album): ?>
      <?php foreach ($album->tags()->split() as $tag): ?>
        <?= $tag ?>
      <?php endforeach ?>
   <?php endforeach ?>

You can use pluck with unique set to to true, which get rid of the dupes.

Just as addendum:

pluck() would have to be used on the pages collection:

$tags = $page->children()->listed()->pluck('tags', ',', true);
 foreach ($tags as $tags): ?>
        <?= $tag ?>
<?php endforeach ?>

Heh Beat me too it… i was just digging in a project for a an example to paste in here…

Thank you for the help.
This is what I have right now and the result is the same tag showed as many times as existing tags there are :-/

  <ul >
      <?php $tags = $Page->children()->listed()->pluck('tags', ',', true);
      foreach ($tags as $tags): ?>
        <li><?= $tag ?></li>
      <?php endforeach ?>

Hrmm that should work, i do basically the same in my own projects. On a side note $Page should be $page

Edit… you have a typo…

foreach ($tags as $tags)

the second should be singular…

foreach ($tags as $tag)
1 Like

Oh amazing… now it works perfectly :slight_smile:
Thanks a lot