The 2013-02-15 release fixed a security issue (XSS vulnerability), if you are using an older version of the tag plugin you should upgrade ASAP!
The Tag Plugin lets you assign category tags to wiki pages.
Updating from before 2012-08-24: Please remove the tag plugin and re-install it as the plugin manager has a bug so the update won't remove no longer needed parts of the plugin. This is a large change to the way the tag plugin stores the tags. If you don't want to wait till the tag index is automatically rebuilt by visiting the pages with the tags, you can rebuild the tag index manually. You also need to update the cloud plugin or the tag cloud won't work anymore.
{{tag>[list of tags]}}
[list of tags] | a space separated list of tags that describe the content of the current page | required |
---|
Allows you to categorize your wiki pages. The resulting links either point to the corresponding page in the specified tag namespace (only if it exists). If you want a link to point to a page in another namespace, you have to indicate the namespace before the tag name. If this page doesn't exist, just the list of pages with the same tag is shown when you follow one of those links.
Examples:
{{tag>tag1 tag2 tag3}}
{{tag>ns1:tag1 ns1:tag2 ns2:subns1:tag3}}
{{tag>tag1_with_multiple_words tag2 tag3_part}}
{{topic>[tag]&[flags]}}
[tag] | the category tag for which you want a list of pages | required |
---|---|---|
[flags] | pagelist flags delimited by & , see flags | optional |
This displays a list of all pages that contain the given category tag. The list is sorted alphabetically by page ID. You can also prepend the modifiers +
and -
. +
creates an intersection between the list of pages created by the already defined tags and the pages matching the tag following the +
(AND), -
removes all pages tagged with the given tag from the list of already found pages.
Example:
{{topic>tag1 -tag2}}
– Lists all pages tagged with tag1 but not with tag2.{{topic>tag1 +tag2}}
– Lists all pages tagged with tag1 and tag2.{{topic>tag1 tag2}}
– Lists all pages tagged with either tag1 or tag2 or both.{{topic>ns1?tag1 tag2}}
– List all pages inside namespace ns1 tagged with either tag1 or tag2 {{topic>.?tag1 tag2}}
– List all pages inside the current namespace tagged with either tag1 or tag2 {{topic>tag1 tag2 tag3&nodate&desc&sort}}
(Adding pagelist options to change the design){{searchtags&[flags]}}
[flags] | pagelist flags delimited by & , see flags | optional |
---|
This displays a search form with the possibility to select a namespace and to select tags from a table of all tags that should either be in- or excluded with the option to choose if the tags should be associated with AND or OR. The results are displayed as in the topic component.
This is a great feature which you should not miss. Please add a screenshot of this cool feature.
And you might check out TagFilter Plugin for similar purpose but in different scenarios.
Example:
{{searchtags}}
– The basic syntax{{searchtags&nodate&desc&sort}}
– with pagelist options to change the design{{count>[tag]}}
[tag] | the category tag for which you want to list the occurrence | required |
---|
This part allows you to display an overview of your current used tags. It prints the tag and the related occurrence (how often is the tag used?) in your wiki. Either you can specify a +
as tag-name, which results in a list of all used tags or just specify some tags separated by spaces.
Example:
{{count>+}}
– List all tags with related occurrences.{{count>tag1 tag2}}
– List the occurrence of tag1 and tag2.{{count>tag1 tag2 tag3&. ns1 ns2}}
– List all occurrences for the given tags inside the namespaces (the dot specifies the root namespace){{tagpage>[tag][&dynamic][|title]}}
This displays a link to the listing of all tags as it is done by the Tag syntax but without tagging the page with that tag. With the optional dynamic
flag the link becomes red when the listing of all pages with that tag is empty for the current user. The dynamic
flag automatically disables the cache of the current page in order to ensure that the link color is always correct. Optionally a title can be specified that will be used as link name.
Example:
{{tagpage>test_foo}}
– The basic syntax{{tagpage>test_foo&dynamic}}
– A link with dynamic link color{{tagpage>test_foo|my title}}
– A link with custom title{{tagpage>test_foo&dynamic|my | title}}
– A link with dynamic link color and custom title (that can also contain |
)The plugin can be configured with the DokuWiki configuration manager available in the admin menu.
namespace | Namespace where the tag plugin looks for existing tag pages and links to them instead of the default tag overview. You could use the topic component to display the list of tags on such a page for example. (default tag ) |
---|---|
sortkey | Order in which tagged pages are sorted in the topic overview; available options are cdate as creation date, mdate as modification date, pagename , id as page ID, ns as namespace and title |
sortorder | Sort order of the topic overview. |
pagelist_flags | Comma separated Flags of the pagelist plugin which is used to display the topic overview |
toolbar_icon | Show icon in page editor toolbar to add tags. |
list_tags_of_subns | When counting tags in specified namespaces include also tags in subnamespaces. |
tags_list_css | Choose tags list style between standard or optimised for top of page position. |
If the tag index becomes corrupted somehow (such as by using page move), then you can rebuild it by using the searchindex plugin or bin/indexer.php.
Development changelog:
Feel free to add yours here:
Just use an “_”, it gets automatically replaced by a “ ” i.e.:
{{tag>tag_with_multiple_words}}
Also, quotes seem to work:
{{tag>"tag with multiple words"}}
This colors the background of the page to red if the keyword 'deprecated' is specified as a tag.
function _handle_keywords(&$data) { global $ID; // Fetch tags for the page; stop proceeding when no tags specified $tags = p_get_metadata($ID, 'subject', METADATA_DONT_RENDER); if(is_null($tags)) true; // Replace underscores with blanks foreach($data->data['meta'] as &$meta) { if($meta['name'] == 'keywords') { $meta['content'] = str_replace('_', ' ', $meta['content']); $t = explode(',', $meta['content']); if(in_array('deprecated', $t)) { $data->data['style'][] = array('type' => 'text/css', '_data' => '.dokuwiki .page {background-color: red;}'); } } } }
If you add at pagelist/helper.php
function tpl_youarehere2_help($id){ $result = ''; global $conf; global $ID; global $lang; // check if enabled if(!$conf['youarehere']) return false; $parts = explode(':', $id); $count = count($parts); // always print the startpage $result .= html_wikilink(':'.$conf['start']); // print intermediate namespace links $part = ''; for($i=0; $i<$count - 1; $i++){ $part .= $parts[$i].':'; $page = $part; if ($page == $conf['start']) continue; // Skip startpage // output $result .= ' » '.html_wikilink($page); } // print current page, skipping start page, skipping for namespace index resolve_pageid('',$page,$exists); if(isset($page) && $page==$part.$parts[$i]) return $result; $page = $part.$parts[$i]; if($page == $conf['start']) return $result; $result .= ' » '.html_wikilink($page); return $result; } function tpl_youarehere2($id) { $str = $this->tpl_youarehere2_help($id); $pos = strrpos($str , '»'); if ($pos == -1) return $str; return substr($str, 0, $pos); } function addPage2($page) { $id = $page['id']; if (!$id) return false; $this->page = $page; $this->_meta = NULL; // priority and draft if (!isset($this->page['draft'])) { $this->page['draft'] = ($this->_getMeta('type') == 'draft'); } $class = ''; if (isset($this->page['priority'])) $class .= 'priority'.$this->page['priority']. ' '; if ($this->page['draft']) $class .= 'draft '; if ($this->page['class']) $class .= $this->page['class']; if(!empty($class)) $class = ' class="' . $class . '"'; $this->doc .= DOKU_TAB.'<tr'.$class.'>'.DOKU_LF; $this->_pageCell($id); if ($this->column['date']) $this->_dateCell(); if ($this->column['user']) $this->_userCell(); if ($this->column['desc']) $this->_descCell(); foreach ($this->plugins as $plug => $col) { if ($this->column[$col]) $this->_pluginCell($plug, $col, $id); } $this->doc .= DOKU_TAB.'</tr>'.DOKU_LF; $this->doc .= DOKU_TAB.'<tr'.$class.'>'.DOKU_LF; $this->doc .= DOKU_TAB.DOKU_TAB.'<td style="padding-left:19px; padding-right:15px; padding-bottom:15px; font-size:10px;">'; $this->doc .= $this->tpl_youarehere2($id); $this->doc .='</td>'.DOKU_LF; $this->doc .= DOKU_TAB.'</tr>'.DOKU_LF; return true; }
And change tag/action.php
$pagelist->setFlags($flags); $pagelist->startList(); foreach ($pages as $page) { $pagelist->addPage($page); }
to
$pagelist->setFlags($flags); $pagelist->startList(); foreach ($pages as $page) { $pagelist->addPage2($page); }
After that, the list of pages that contain the tag, except for the names of pages themselves under them will also be bread crumbs to these pages.
Integrated to main code (see tags_list_css
) option
When you insert the syntax at the top of a wiki page, the output of the plugin will be displayed below the TOC (Table of Contents). To make the visual appearance more smooth, change your lib/plugins/tag/style.css
to the following code:
div.dokuwiki div.tags { border-top: 2px dotted __border__; font-size: 95%; text-align: right; /* clear: both; */ }
Is it possible to change the word tag used in syntax to something else, like another language {{tagInMylanguage>someTag}} –damascene 2012/04/10
I want the description under the tag, is it possible to make a line brake or to get the description under the tag? Thx
Is there any tip for hierarchical tag? I try to categorize my pages. For example, there are two pages. A Persian cat page has {tag>animal:cat}. And a Dalmatian dog page has {tag>animal:dog}. If I write '{topic>animal}, I hope to see the two pages, but all I can see is blank. Yes, I can tag that {tag>animal dog}, {tag>animal cat}, but it is not fancy.
How do I tag a page? Lots of detail about how to display tagged pages, but I cannot find anything about how to tag a page to begin with.
You have to type it into the page. Look at the Components portion of this page to see what to type.
For bugs or feature requests, there is the bug tracker linked here : Bug tracker.
This plugin clashes with the include module of the mediasyntax plugin. One workaround is to disable that part of the mediasyntax plugin by renaming the include.php file.
If you have a tag name that is the same as a page name that already exists, the tag links will point to that page in the current namespace rather than the page name in the tag namespace. Is this a bug or a feature? (3-Aug-2011)?
Found the issue. If you do not specify a namespace, it defaults to whatever is defined as the default namespace (ie. root:tag). If you do specify a namespace, it makes whatever you specify as the location for the data file (ie. root:mynamespace), NOT root:tag:mynamespace.
My wiki has about 7000 pages with tags. It takes 25 seconds to display ~~TAGCLOUD~~ (My server runs with latest NGINX, UBUNTU 12.04, 4 core i5 cpu with 8gb ram, intel SSD ). Anyone have any other suggestion? or Do I need SQL-based tagging solution? — S.C. Yoo 2014/04/19 06:02
Individual Search Form: I'd like a form where the user could just type in the tag name, click search, and then a list is generated below. I know you got the searchtags but its just going to get unwieldy with the amount of tags I'm envisioning having. Thanks
Structured Tags: Can this (or any other plugin) support structured tags in addition to free-form tags? – 2014-09-02
I'm using Dokuwiki under Debian, last version in Debian distro. I installed plugin tags, but don't work :(
All page with {{tag>name_tag}} results a blank page, including the content of the page. I don't know what don't work but, I can't use it :(
I am using Debian Wheezy and I am having the same issue.
»»»»» Hy, I think the tag should be separted by a “,”. I mean what happen if I wanna tag “New York City” ? In present is created separte tag for “new” “york” “city” and that's not really good. — A.V
Same here, get a Nothing was found page.
(2017-03-28) I had the same problem. By coincidence, I switched to the default Dokuwiki template for an unrelated reason and got a different error when I clicked a tag link: “Helper plugin pagelist is not available.” Installed the pagelist plugin and then it worked. This dependency needs to be documented.
Does this plugin alter the meta tags of the rendered pages? If it doesn't, I would like to leave the suggestion. — Fabricio Rocha 2016-06-11 17:00
Is there any way to sort the output of the {{count>}} command? I'd like to have a page of used tags in alphabetical order, but it seems that pagelist parameters are not supported. — Fabricio Rocha 2016-06-19 19:42
This can be achieved by editing the helper.php
file of the plugin. Before the return $otag;
line within the function tagOccurrences
, just insert the line ksort($otags);
and that's all. IMO this should be standard behavior. — Taylan
Is there a way to gen an unorderd list of all tags, similar as
Tag | # |
---|---|
action | 1 |
platformer | 1 |
1991 | 1 |
286 | 1 |
def | 1 |
apogee software | 1 |
ega | 2 |
cga | 2 |
tuv | 2 |
strategy | 2 |
1987 | 1 |
intel 80186 and earlier | 2 |
spectrum holobyte | 1 |
tandy | 1 |
pcjr | 2 |
system articles | 14 |
steptail | 2 |
support | 1 |
1985 | 1 |
todo | 2 |
daniel lawrence | 1 |
daniel lawrence | 1 |
developers | 1 |
publishers | 1 |
guides | 18 |
hardware | 1 |
software | 4 |
networking | 12 |
olpc xo-1 | 2 |
, but without table and occurrences?
Hi, I have attempted to try an solve this but my apologies as I do not know enough about PHP. I use some tags on the site to create dynamic links and I was wondering if there is a way to have the tagsearch have the capability to ignore certain tags. In this case I start the dynamic tags with dw_ and would like to know if possible to filter out all the tags that start with dw_. Thanks for any help! Frank.