# Tagcloud don't work

**URL:** <https://forum.getkirby.com/t/tagcloud-dont-work/2053>\
**Category:** Questions\
**Tags:** v2\
**Created:** [September 20, 2015, 4:59pm UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053 "2015-09-20T16:59:53Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![zauberweib](https://avatars.discourse-cdn.com/v4/letter/z/ce7236/32.png) [@zauberweib](https://forum.getkirby.com/u/zauberweib)\
**Post date:** [September 20, 2015, 4:59pm UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053/1 "2015-09-20T16:59:53Z")

</div>

I used kirby last year. But I want some tagcloud and that didn’t worked, so I took some other cms (nibbleblog).

Now I want give kirby2 a new chance - but tagcloud don’t work. I took it from github, read the readme-file 🙂 The tags were shown where they should. On klick there is the correct url in browser but _shown_ is the error-page. Why??

As plan B I want to “install” the search (I wonder why this is not ready by the starter-kit?), but this won’t work.

I have installed kirby on Xampp-Portable and I tried the whole sunday getting tagcloud or search running. I did everything step by step installing the search2, suddenly nothing would shown! after deleting every “search”-files everything was well again.

what is wrong?

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [September 20, 2015, 7:49pm UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053/2 "2015-09-20T19:49:38Z")

</div>

Welcome to the forum!

The tagcloud plugin is only responsible for the, well, tagcloud. As your setup can be totally custom, you need to implement the filter yourself. But don’t worry, that’s quite easy: [http://getkirby.com/docs/solutions/blog/tags#controlling-the-filter-by-url](http://getkirby.com/docs/solutions/blog/tags#controlling-the-filter-by-url)

---

<div class="post-metadata">

**Author:** ![zauberweib](https://avatars.discourse-cdn.com/v4/letter/z/ce7236/32.png) [@zauberweib](https://forum.getkirby.com/u/zauberweib)\
**Post date:** [September 20, 2015, 10:42pm UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053/3 "2015-09-20T22:42:10Z")

</div>

thanks for your answer. the problem is now different; klick on a tag brings no longer the error-page - it shows the same site I klicked on. browser shows the correct url.

I’ve gone through the tutorial and made a controllers/blog.php - nothing changed.

Maybe I expect the false things should happen by klick on a tag in the tagcloud/list. In my opinion I should get a list (titles, excerpts, full articles, …) with all blogpost (childs) having this tag.

Am I wrong? How can I get this?

Thanks a lot from my worried mind 🙂

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 21, 2015, 5:40am UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053/4 "2015-09-21T05:40:10Z")

</div>

What you expect is completely correct, that’s the way it works if it is implemented correctly. Could you post your code (just the bits that refer to the tags cloud, with the files that code is in)? Where have you placed your tag cloud?

As regards the search, have a look at the Baseblog Kirby Theme for an example of an implementation: [https://github.com/sashtown/baseblog](https://github.com/sashtown/baseblog)

---

<div class="post-metadata">

**Author:** ![zauberweib](https://avatars.discourse-cdn.com/v4/letter/z/ce7236/32.png) [@zauberweib](https://forum.getkirby.com/u/zauberweib)\
**Post date:** [September 21, 2015, 11:40am UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053/5 "2015-09-21T11:40:39Z")

</div>

Ok, thanks a lot!  
I have copied the tagcloud.php from [https://github.com/getkirby/plugins/blob/master/tagcloud/tagcloud.php](https://github.com/getkirby/plugins/blob/master/tagcloud/tagcloud.php) (marked the whole file, copy and create some new with this content) to the plugins-folder (site/plugin)

In the blog.php-template I have copied as told on the github-page:

```
 <?php $tagcloud = tagcloud(page('blog'), array()) ?>
<ul>
<?php foreach($tagcloud as $tag): ?>
  <li><a href="<?php echo $tag->url() ?>"><?php echo $tag->name() ?></a></li>              
<?php endforeach ?>
</ul>

```

I’ve copied this between

```
</section> and <?php snippet('footer') ?> 

```

(I just want to see it running, before I care about nice design 🙂 )

On the template for the blog-entries filled in some:

```
<?php echo $page->tags()->kirbytext() ?>

```

And of course in the entries-txt-files some i.e. “tags: nice, day, something, what”…  
Whats missing? Whats wrong? I didn’t get it…_rolleyes_

Thanks for helping. I have installed the kirby 211 and I’m just taking the example-content. As I say: first running… _sfz_

greetings,  
Zaubi

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 21, 2015, 12:24pm UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053/6 "2015-09-21T12:24:41Z")

</div>

I’m missing the blog.php controller in the above … It should have the filter for the tags to make filtering work:

```php
<?php

return function($site, $pages, $page) {
  $tag = urldecode(param('tag'));
    if(param('tag')) {
    	$articles = page('blog')->children()->visible()->filterBy('tags', $tag,',')->sortBy('date')->flip();
    } else {
    	$articles = page('blog')->children()->visible()->sortBy('date')->flip();}
   
   return compact('articles');

};

```

---

<div class="post-metadata">

**Author:** ![zauberweib](https://avatars.discourse-cdn.com/v4/letter/z/ce7236/32.png) [@zauberweib](https://forum.getkirby.com/u/zauberweib)\
**Post date:** [September 21, 2015, 2:17pm UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053/7 "2015-09-21T14:17:43Z")

</div>

You’re right, this I have forgotten to post, but I have it. Tried it with your code - even the same result:  
On klick to a tag I see in Browser i.e. …kirby211/blog/tag:basteln and it shows the same blog-“startpage” with the list of tagcloud in the end.

Nothing I have to set in the template for the single blog-entries? What is the part of code that says what should happen when browser says “…kirby211/blog/tag:basteln” - that is what I’m missing bzw. I don’t understand where this part is.

greetings  
zaubi

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 21, 2015, 3:58pm UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053/8 "2015-09-21T15:58:29Z")

</div>

How do you display your list of articles in your blog.php? You should have something like this:

```php
<?php foreach($articles as $article) : >
<h2><?php echo $article->title()->html() ?></h2>
<?php echo $article->text()->excerpt(80) ?>
<?php endforeach ?>

```

Sounds as if all you have in your blog.php is the tag cloud? If so, then you cannot filter anything …

---

<div class="post-metadata">

**Author:** ![zauberweib](https://avatars.discourse-cdn.com/v4/letter/z/ce7236/32.png) [@zauberweib](https://forum.getkirby.com/u/zauberweib)\
**Post date:** [September 21, 2015, 6:54pm UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053/9 "2015-09-21T18:54:01Z")

</div>

I have, the full blog-template is:

```
<?php snippet('header') ?>
<section class="content blog">  
<h1><?php echo $page->title()->html() ?></h1>
  <?php echo $page->text()->kirbytext() ?>

  <?php foreach($page->children()->visible()->flip() as $article): ?>
  <article>    
  <h2><a href="<?php echo $article->url() ?>"><?php echo $article->title()->html() ?></a></h2>  
  <p><?php echo $article->text()->excerpt(100) ?></p>    
  <p><b>Tags:</b> <?php echo $article->tags()->html() ?></p>    
  <a href="<?php echo $article->url() ?>">mehr</a>  
  </article>  
<?php endforeach ?>

</section>

<?php $tagcloud = tagcloud(page('blog'), array()) ?>
<ul>
<?php foreach($tagcloud as $tag): ?>  
<li><a href="<?php echo $tag->url() ?>"><?php echo $tag->name() ?></a></li>
<?php endforeach ?>
</ul>
<?php snippet('footer') ?>

```

By klick on a tag in the taglist the correct url is shown in browser, but only the blog-page would be reloaded, thats it. ☹

greetings  
zaubi

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 21, 2015, 7:27pm UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053/10 "2015-09-21T19:27:43Z")

</div>

Oh, I see. But the problem is the following line:

```php
<?php foreach($page->children()->visible()->flip() as $article): ?>

```

This means that you display all articles all the time and the filter in your blog.php controller will not work.

If you define $articles in your controller as explained above, you need to use it in your template, so change the above line to:

```php
<?php foreach($articles as $article): ?>

```

That way, when you just call the blog page without the tag parameter, you get the full list of articles; if you open a tag link, the article filter will be applied and you get the filtered list.

---

<div class="post-metadata">

**Author:** ![zauberweib](https://avatars.discourse-cdn.com/v4/letter/z/ce7236/32.png) [@zauberweib](https://forum.getkirby.com/u/zauberweib)\
**Post date:** [September 21, 2015, 7:38pm UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053/11 "2015-09-21T19:38:55Z")

</div>

WOWHHHH!! Thanks a lot! _bigsmile_ Now its running! 🙂 You make me happy! 🙂 Thanks!

Now I can look to _understand_ whats gone wrong. But first: it works! _straaaaaahl_

Thanks so much! I’m soooo happy! Thanks!!

bigsmilegreetings  
zaubi

---

<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:00pm UTC](https://forum.getkirby.com/t/tagcloud-dont-work/2053/12 "2025-02-06T17:00:26Z")

</div>

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


