====== Tag Plugin ====== ---- plugin ---- description: Assign category tags to wiki pages. (previous authors: Esther Brunner) author : Gina Häußge, Michael Klier email : dokuwiki@chimeric.de type : syntax, action, helper lastupdate : 2011-09-04 compatible : Lemming, Anteater, Rincewind, Angua depends : pagelist conflicts : similar : tags : navigation, blog, tags, listing downloadurl: http://github.com/dokufreaks/plugin-tag/tarball/master bugtracker : http://github.com/dokufreaks/plugin-tag/issues sourcerepo : http://github.com/dokufreaks/plugin-tag/ donationurl: ---- ===== Description ===== The Tag [[plugins|Plugin]] lets you assign category tags to wiki pages. ===== Components ===== ==== Tag ==== {{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}}%%'' * with namespaces: ''%%{{tag>:ns1:tag1 ns1:tag2 ns2:subns1:tag3}}%%'' ==== Topic ==== {{topic>[tag]&[flags]}} ^ [tag] | the category tag for which you want a list of pages | required | ^ [flags] | pagelist flags delimited by ''&'', see [[pagelist#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 [[:plugin:pagelist|pagelist]] options to change the design) ==== Count ==== {{count>[tag]}} ^ [tag] | the category tag for which you want the list the occurrence | required | This part allow 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) ===== Configuration ===== 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'') | ^ ''pingtechnorati'' | Enable/disable Technorati pinging. | ^ ''sortkey'' | Order in which tagged pages are sorted in the topic overview; available options are creation date, modification date, page name, page ID and title | ^ ''sortorder'' | Sort order of the topic overview. | ^ ''pagelist_flags'' | Comma separated [[plugin:pagelist#Flags]] of the [[plugin: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. | ===== Tagindex Rebuild ===== If the tag index becomes corrupted somehow (such as by using page move), then you can rebuild it by using the "Tagindex Manager" link on the admin page. Index corruption may show itself by the cloud plugin showing the wrong popularity weights in the tag cloud. Note that the dialog suggests to back up "tag.idx", where the actual file name is "topic.idx". ===== Ping ===== This plugin may automatically ping Technorati on the creation of a new page. This behavior can be turned on in the configuration manager. ===== Demo / Screenshots ===== You can see the plugin in action [[http://chimeric.de/_demo/plugin:tag|here]]. FIXME (link broken) {{ http://dump.lupo49.de/tmp/dokuwiki/plugin_screenshots/tag/tag_overview.png?283x205 }} {{ http://dump.lupo49.de/tmp/dokuwiki/plugin_screenshots/tag/tag_page.png?200x58 }} ===== Changes ===== {{rss>http://github.com/feeds/dokufreaks/commits/plugin-tag/master date}} ===== FAQ ===== ==== How to use tags which consist of multiple words? ==== 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"}} ==== Change CSS styles depending on existing tags ==== 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;}'); } } } } ==== Bad appearance when displaying tags at top of page ==== 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; */ } ===== Localization ===== The localization should be fixed here: - print $this->getLang('rebuildindex'); + print 'Rebuild Tagindex'; #FIXME localize --- [[user>danny0838|danny0838]] //2011/10/23 03:31// > What do you mean? There's a related getLang() entry inside lang/en/lang.php? --- [[user>lupo49|M. S.]] //2011/10/23 16:45// ===== Discussion ===== For __**bugs or feature requests, there is the bug tracker**__ linked here : [[http://github.com/dokufreaks/plugin-tag/issues|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. * Is there no way to display all used tags? This would be very useful for finding typos and (nearly) duplicate entries. (2012-02-21) * Sry, me stupid, it works with count... **BUG** except that the table-entries are empty in my wiki! Latest DW/Plugin, with %% ~~NOCACHE~~ %% [[http://imgur.com/73Yuj|Screenshot]]. Sry for not registering at github for this. * In most of my installation it works, in some not... clueless!