Table of Contents
Cloud Plugin
Compatible with DokuWiki
- 2022-07-31 "Igor" yes
- 2020-07-29 "Hogfather" yes
- 2018-04-22 "Greebo" yes
- 2017-02-19 "Frusterick Manners" yes
Similar to cumulus
Description
This is a very simple plugin that shows a cloud of the most frequently used words in your wiki:
~~CLOUD~~ ~~CLOUD:number~~
Optionally you can specify the number of words to display. Default is 50. Allowed are numbers between 1 and 999. Each of the words is linked to the search result page for it. The words are styled in a way that more frequent words are bigger and have a darker link color.
You can exclude words from the word cloud by adding them each on its own line to inc/lang/[lang-code]/stopwords.txt
or to conf/stopwords.txt
. Remember that last line in file should be empty to work correctly.
This plugin can also make a “tag cloud” now! (tag plugin must be installed) The syntax is also simple:
~~TAGCLOUD~~ ~~TAGCLOUD:number~~ ~~TAGCLOUD:number>namespace1:subns11|.|namespace2~~
It also supports clouds for the most searched words in the wiki (searchstats plugin must be installed):
~~SEARCHCLOUD~~ ~~SEARCHCLOUD:number~~
Since release 2017-08-05 the number of occurrences can also be output by adding the showCount
option like this:
~~CLOUD[showCount]~~
Modifying the style
Since release 2017-08-05 the CSS style of the cloud is defined in style.less
instead of style.css
. The less code makes it easier to modify the look of the cloud.
To modify the text size in the cloud only the size factor sF
needs to be changed. The following example doubles the size by changing the size factor from 1 to 2:
/* Size factor. */ @sF: 1; .dokuwiki div.cloud { margin-bottom: 1em; line-height: 145% * @sF; } ...
To change the color modify one of the three base color values in c0
, c1
or c2
. The following code will make the cloud have a lime green base color:
... @c0: #32CD32; .dokuwiki div.cloud a.cloud1 { font-size: @f1; color: desaturate(lighten(@c0, 4 * @l), 4 * @d); } .dokuwiki div.cloud a.cloud2 { font-size: @f2; color: desaturate(lighten(@c0, 3 * @l), 3 * @d); } .dokuwiki div.cloud a.cloud3 { font-size: @f3; color: desaturate(lighten(@c0, 2 * @l), 2 * @d); } .dokuwiki div.cloud a.cloud4 { font-size: @f4; color: desaturate(lighten(@c0, 1 * @l), 1 * @d); } .dokuwiki div.cloud a.cloud5 { font-size: @f5; color: @c0; } ...
Please only use RGB color values here, not CSS color names.
Development
Changes
- 2013-02-27:
- Fixed stopwords. Note that stopwords are only for the word cloud and not for the tag or searchstats cloud.
- Added different text sizes for the searchstats cloud
- Changed HTML output to be valid when more than one cloud is used on a page, if you had adapted the colors/styling of the tag cloud you need to adapt your CSS (the
cloud
id was changed into a class).
Most recent code changes:
- Merge pull request #86 from dokuwiki-translate/lang_update_547_167457… (2023-01-24 19:29)
- translation update (2023-01-24 15:45)
- Version upped (2022-09-28 23:50)
- Merge pull request #84 from dregad/php8-warnings (2022-09-28 23:00)
- Delete .gitignore (2022-09-28 23:00)
- Forward-compatible approach to initialize flags (2022-09-27 23:43)
- Remove code leftover from the switch to array_pad() (2022-09-27 01:11)
- Add .gitignore (2022-09-26 12:43)
Bugs/Feature Requests
Please report bugs and feature requests at the Bug Tracker.
Demo
The plugins page of dokuwiki.org presents a tag cloud that refers to all pages in the plugin name space.
Site using this plugin
- http://wiki.zebras-crossing.org (it is a TAGCLOUG modified with the CLOUD colors)
FAQ
Caching for clouds
Hi, is it possible to cache the cloud? If i activate the plugin on my page, it slows down my system very much.
You can enable the caching feature by setting $renderer→info['cache'] = false; in syntax.php line 74 to true.
Whitespaces in Tags
Use underscores to specify whitespaces in tags.
Cloud in Windows-Server
You run cloud on a Windows server. The stylesheet style.css
must be edited to hold Windows linebreaks rather then Unix. This solved the same problem for me. Ruud
More than one Cloud on a page
When you have more than one cloud (eg. a word and a tag cloud) on a page you end up with invalid HTML because each cloud has the same id (<div id="cloud">…
), id's must be unique within a page.
Fixed int he 2013-02-27 version — Michael Hamann 2013/02/27 23:50
Discussion
The old discussion has been moved to discussion_old and will be cleaned up sooner or later. Please add bug reports and feature requests to the bug tracker of the plugin!
Related to the previous suggestion for tagcloud; If the first heading exists in a page of the specified tag, I'd like the tag-clouds to appear the first heading of the tag page.
I have one problem that the size of each tag remain the same, does not change. I am using a sandy.
SEARCHCLOUD Size
When a searchcloud is rendered, the size of each search term remains the same (cloud5). Kludgy fix:
After
$cloud = $helper->getSearchWordArray($num);
Add
ksort($cloud); // optional, changes sort from hit count to alphabetical if ($num != 50) { // if not the default cloud size $min=1; // set the minimum to 1 to ease the tiny text problem } else { $min=true; } $max=true; foreach ($cloud as $word => $size) { $min = min($size,$min); $max = max($size,$max); }
(Different) fix is in the 2013-02-27 version — Michael Hamann 2013/02/27 23:50
Stopwords in tag clouds?
I was trying to remove some tags from the tag cloud as I have nested tags as a structuring element but due to this, certain tags appear much more often than others (the 'folder' tags). However, the described methods (include stopwords.txt in conf/ or inc/lang/) apparently do not work for tag clouds. Is there some way to have the clouds behave the way I would like them to? — Cantello 2011/11/30 19:40
stopwords are only for the word cloud, not for the tag cloud. I consider adding a similar (but differently named) blacklist for the tag cloud. — Michael Hamann 2013/02/27 23:50
patch to fix stopwords
@Cantello — I've attached a simple one-liner patch that helped me fix the same problem. It turns out that there's a single space that's not trimmed from the $stopwords array in the syntax.php file… hence array_search($key, $stopwords) never returns True.
— skipliquid # skipliquid # at # g # mail # dot # com
2012/1/31 14:00
- cloud_stopwords-fix.diff
--- syntax.php.orig 2012-01-31 14:24:50.000000000 -0500 +++ syntax.php 2012-01-31 14:47:57.849347682 -0500 @@ -142,6 +142,7 @@ $swfile = DOKU_CONF.'stopwords.txt'; if (@file_exists($swfile)) $stopwords = array_merge($stopwords, file($swfile)); + $stopwords = array_filter(array_map('trim', $stopwords)); $cloud = array(); if (@file_exists($conf['indexdir'].'/page.idx')) { // new word-length based index
Thanks @ skipliquid! Where do I have to implement that code or the file? Best regards, flu.
A different fix for this problem is in the 2013-02-27 version. — Michael Hamann 2013/02/27 23:50
Tagcloud links to pages
Using Dokuwiki release Adora belle with tag and cloud plugin:
Some of my tags and some of my page names equal. If such a tag appears in the tagcloud, the cloud item will link to the page with the equal name and not to the list of pages, that are tagged with the tag.
Julian 2013-02-16
This is intentional in order to give you the possibility to add a description for that tag on this page. You can use the topic syntax of the tag plugin in order to add the list of pages to the description of the tag. — Michael Hamann 2013/02/16 13:45
Thank you!
Manolito 2013-02-21
Can we force the tag's link in cloud to a page defined in advance in subnamespace ? By default, the link leads in a page autogenerated like “tag:tag1”. I would like to report “tag1” in address like “en:tag:ns1:ns2:tag1”. This is my way of organizing the navigation menu almost auto-generated which created this particular request… and with plugin multilingue it's better too. — Alinea 2013/03/09 12:17
Tag namespace feature request
It would be nice if you could also control what tag namespace to use as it is with page namespaces now.
For example, you tag some of your pages withtopic1
,topic2
,myCategory:subTopic1
,myCategory:subTopic2
and then you create a tagcloud restricting it tomyCategory
to get onlysubTopic1
andsubTopic2
listed there.
— Seykela 2013/02/22 15:59
I agree with this, it would be a great feature!
— Fernando Ribeiro 2013/05/02 14:41
I would also like to see this functionality. It would be excellent if (just as in the SEARCHCLOUD syntax) a cloud could be generated from the resullts of a TagFilter plugin listing.— JD4x4
Show the number of occurences for each tag
Could you please tell me how can i show the number of occurences of each tag of the cloud, such as keyword(number)..
Thank u
Steve 19/08/2013