Tagcloud don't work

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 :slight_smile: 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?

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

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 :slight_smile:

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

Ok, thanks a lot!
I have copied the tagcloud.php from 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 :slight_smile: )

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

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

<?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');

};

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

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

<?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 …

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. :frowning:

greetings
zaubi

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

<?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 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.

1 Like

WOWHHHH!! Thanks a lot! bigsmile Now its running! :slight_smile: You make me happy! :slight_smile: 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

1 Like