# Tag Cloud with multiple page templates

**URL:** <https://forum.getkirby.com/t/tag-cloud-with-multiple-page-templates/506>\
**Category:** Questions\
**Tags:** v2\
**Created:** [March 17, 2015, 7:02pm UTC](https://forum.getkirby.com/t/tag-cloud-with-multiple-page-templates/506 "2015-03-17T19:02:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AhoyLemon](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahoylemon/32/4762_2.png) [@AhoyLemon](https://forum.getkirby.com/u/AhoyLemon)\
**Post date:** [March 17, 2015, 7:02pm UTC](https://forum.getkirby.com/t/tag-cloud-with-multiple-page-templates/506/1 "2015-03-17T19:02:06Z")

</div>

Hey all,

I’m trying to use the Kirby tagcloud plugin to make one giant page of tags, prioritized by popularity and with a count. I’m close to a solution, except the tagcloud plugin seems to only want to pull from one page template. Ideally I’d love it if I could give it multiple templates to pull tags from.

Here’s what I’ve got so far…

```auto
<?php $tagcloud = tagcloud(page('episode')) ?>
  <article class="full">
    <ul class="tagcloud episode-tags">
      <?php foreach($tagcloud as $tag): ?>
      <li>
        <?php $x = 0; ?>
        <?php $tagmatches = $site->grandChildren()->filterBy('template','episode')->filterBy('tags', $tag->name(), ','); ?>
        <?php foreach($tagmatches as $tagmatch): $x = $x+1; ?>
        <?php endforeach ?>
        <a <?php if ($x > 1): ?> href="<?php echo url::home() ?>/find/tag:<?php echo rawurlencode($tag->name()) ?>" <?php endif ?>><?php echo trim($tag->name()) ?> (<?php echo $x; ?>)</a>
      </li>
      <?php endforeach ?>
    </ul>
  </article>

```

…which gives me [this result](http://thefpl.us/tags).

That’s great, but I’d like to have the tagcloud function go through the ‘blog’ and ‘other-projects’ templates as well as episode. On a whim, I’ve tried several variants of `<?php $tagcloud = tagcloud(pages('episode', 'blog', 'other-projects) ?>`, but those attempts just break the page.

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [March 17, 2015, 7:12pm UTC](https://forum.getkirby.com/t/tag-cloud-with-multiple-page-templates/506/2 "2015-03-17T19:12:50Z")

</div>

Look here in the Tagcloud section: [http://getkirby.com/docs/solutions/blog/tags](http://getkirby.com/docs/solutions/blog/tags)

```php
// fetch all tags
$tags = $page->children()->visible()->pluck('tags', ',', true);

```

---

<div class="post-metadata">

**Author:** ![AhoyLemon](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahoylemon/32/4762_2.png) [@AhoyLemon](https://forum.getkirby.com/u/AhoyLemon)\
**Post date:** [March 17, 2015, 7:32pm UTC](https://forum.getkirby.com/t/tag-cloud-with-multiple-page-templates/506/3 "2015-03-17T19:32:02Z")

</div>

Hey distantnative,

Thanks, I did try the pluck() option, except that sacrificed the ability to sort the tags based on popularity, which I didn’t really want to give up.

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [March 17, 2015, 8:06pm UTC](https://forum.getkirby.com/t/tag-cloud-with-multiple-page-templates/506/4 "2015-03-17T20:06:59Z")

</div>

Maybe then something like:

```php
$tags = page('episode')->children()->pluck('tags', ',', true);
$tags = array_map(function($tag) { 
  $count = page('episode')->children()->filterBy('tags', $tag, ',')->count();
  return array('name' => $tag, 'count' => $count);
}, $tags);

```

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:17pm UTC](https://forum.getkirby.com/t/tag-cloud-with-multiple-page-templates/506/5 "2025-02-06T17:17:40Z")

</div>

Archived on February 6, 2025, 5:17pm UTC


