A tag cloud is a collection of words in one place, a depiction of the text content of your publication. Normally, tags are listed alphabetically, and the importance of each tag is shown with font size or colour. To make a tag cloud in Newscoop, we can use topics and sub-topics. First, you will need to create a list of Newscoop sub-topics, having the parent topic 'tagcloud':
Then, you will just need to attach the required sub-topics to an article:
Then, you need to create a Tag Cloud template. Please note that this template will be doing a lot of listings, so it might be a good idea to put it a cron job to produce the output, and place the result in a file for further inclusion from other templates.
The first thing to do will be to list all sub-topics (tags) of the main topic 'tagcloud' and get minimum and maximum numbers of articles having each topic. Also, we need to set up font-size ranges for the output:
{{ local }} {{ unset_issue }} {{ unset_section }} {{ unset_article }} {{ unset_topic }} {{ set_topic name="tagcloud:en" }} {{ assign var="first_good_tag" value=true }} {{ list_subtopics }} {{ assign var="posts_count" value="0" }} {{ list_articles ignore_issue="true" }} {{ assign var="posts_count" value=$gimme->current_list->count }} {{ /list_articles }} {{ if $posts_count > 0 }} {{ if $first_good_tag }} {{ assign var="min" value=$posts_count }} {{ assign var="max" value=$posts_count }} {{ assign var="first_good_tag" value=false }} {{ /if }} {{ if $posts_count > $max }} {{ assign var="max" value=$posts_count }} {{ /if }} {{ if $posts_count < $min }} {{ assign var="min" value=$posts_count }} {{ /if }} {{ /if }} {{ /list_subtopics }} {{ assign var="minSize" value="90" }} {{ assign var="maxSize" value="240" }} {{ assign var="diff_max_min" value="`$max-$min`" }} {{ assign var="diff_maxSize_minSize" value="`$maxSize-$minSize`" }}
Next, we create the actual output. List sub-topics, get articles having each sub-topic, and assign the number of times the sub-topic was used:
<ul class="tag-cloud"> {{ list_subtopics }} {{ assign var="posts_count" value="0" }} {{ list_articles ignore_issue="true" }} {{ assign var="posts_count" value=$gimme->current_list->count }} {{ assign var="tag_name" value=$gimme->topic->name }} {{ /list_articles }}
Then we calculate font size for the sub-topic in the tag cloud:
{{ if $posts_count > 0 }} {{ if $min == $max }} {{ assign var="fontSize" value="`$diff_maxSize_minSize/2+$minSize`" }} {{ else }} {{ assign var="a" value="`$posts_count-$min`" }} {{ assign var="b" value="`$a/$diff_max_min`" }} {{ assign var="fontSize" value="`$b*$diff_maxSize_minSize+$minSize`" }} {{ /if }}
And finally output the result:
<li> <span style="}}%"><a href="/?tpl=special_template_to_list_articles_based_on_topic.tpl&tag={{ $tag_name }}" title="{{ $posts_count }} articles having topic {{ $tag_name }}">{{ $tag_name }}</a></span> </li> {{ /if }} {{ /list_subtopics }} </ul> {{ /local }}
As a result, you should get a Tag Cloud like the following screenshot:
Tag cloud created using topics
There has been error in communication with Booktype server. Not sure right now where is the problem.
You should refresh this page.