DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:tag

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:tag [2017-03-29 00:00] – [Discussion] 216.66.188.62plugin:tag [2024-01-19 23:43] (current) – [Demo / Screenshots] Aleksandr
Line 6: Line 6:
 email      : freaks@dokuwiki.org email      : freaks@dokuwiki.org
 type       : syntax, action, helper type       : syntax, action, helper
-lastupdate : 2016-01-16 +lastupdate : 2023-10-17 
-compatible : Weatherwax, Binky, Ponder Stibbons, Hrun, Detritus, Elenor of Tsort+compatible : Weatherwax, Binky, Ponder Stibbons, Hrun, Detritus, Elenor of Tsort, Frusterick Manners, !Greebo, Hogfather, Igor, Jack Jackrum
 depends    : pagelist depends    : pagelist
 conflicts  conflicts 
Line 18: Line 18:
 donationurl: http://www.content-space.de/dokuwiki/donate donationurl: http://www.content-space.de/dokuwiki/donate
 ---- ----
- 
-:!: 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! :!: 
  
 ===== Description ===== ===== Description =====
  
-The Tag [[plugins|Plugin]] lets you assign category tags to wiki pages. +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>2594|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 [[#Tagindex Rebuild|rebuild]] the tag index manually. You also need to update the [[cloud]] plugin or the tag cloud won't work anymore. 
  
 ===== Components ===== ===== Components =====
  
 ==== Tag ==== ==== Tag ====
 +Add a tag to the page
  
   {{tag>[list of tags]}}   {{tag>[list of tags]}}
-  +
 ^ [list of tags]  | a space separated list of tags that describe the content of the current page  | required  | ^ [list of tags]  | a space separated list of tags that describe the content of the current page  | required  |
  
Line 40: Line 39:
   * ''%%{{tag>tag1 tag2 tag3}}%%''    * ''%%{{tag>tag1 tag2 tag3}}%%'' 
   * with namespaces: ''%%{{tag>ns1:tag1 ns1:tag2 ns2:subns1:tag3}}%%''   * with namespaces: ''%%{{tag>ns1:tag1 ns1:tag2 ns2:subns1:tag3}}%%''
-  * mutiple word tags: ''%%{{tag>tag1_with_multiple_words tag2 tag3_part}}%%''+  * multiple word tags: ''%%{{tag>tag1_with_multiple_words tag2 tag3_part}}%%'' 
 +  * ''%%{{tag>"tag with spaces" tag2}}%%'' -- Within quotes you can use spaces. Tag is stored internally with underscores ''_''.
  
  
 ==== Topic ==== ==== Topic ====
 +List all pages with given tags. 
   {{topic>[tag]&[flags]}}   {{topic>[tag]&[flags]}}
  
Line 50: Line 50:
 ^ [flags]  | pagelist flags delimited by ''&'', see [[pagelist#flags]]  | optional  | ^ [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.+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 ''-''
 +  * If you do not prepend, it acts as a OR. A page is added if it has one of these tags. 
 +  * ''+'' creates an intersection between the list of pages created by the already defined tags and the pages matching the tag following the ''+'' (AND), so each listed page must have this tag. 
 +  * ''-'' removes all pages tagged with the given tag from the list of already found pages (NOT).
  
 Example:  Example: 
Line 61: Line 64:
  
 ==== Searchtags ==== ==== Searchtags ====
 +Search form for filtering by tag.
  
    {{searchtags&[flags]}}    {{searchtags&[flags]}}
Line 75: Line 79:
   * ''%%{{searchtags}}%%'' -- The basic syntax   * ''%%{{searchtags}}%%'' -- The basic syntax
   * ''%%{{searchtags&nodate&desc&sort}}%%'' -- with [[:plugin:pagelist|pagelist]] options to change the design   * ''%%{{searchtags&nodate&desc&sort}}%%'' -- with [[:plugin:pagelist|pagelist]] options to change the design
 +  * ''%%{{searchtags&nonsform}}%%'' -- hide the namespace selector
 +
 +
 +
 ==== Count ==== ==== Count ====
 +Shows a list of tags and its number of occurrences.
  
-  {{count>[tag]}}+  {{count>[tag][&namespace]}}
  
-^ [tag] | the category tag for which you want the list the occurrence | required |+^ [tags The tag for which you want to list the occurrence. Multiple tags separated by spaces.   | optional 
 +^ &[namespaces]  | Counts occurrences for given tags only at pages inside the given namespaces. Multiple namespaces separated by spaces. optional  |
  
-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.+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 ''+'' (or empty) as tag-name, which results in a list of all used tags or just specify some tags separated by spaces.
  
 Example: Example:
   * ''%%{{count>+}}%%'' -- List all tags with related occurrences.   * ''%%{{count>+}}%%'' -- List all tags with related occurrences.
   * ''%%{{count>tag1 tag2}}%%'' -- List the occurrence of tag1 and tag2.   * ''%%{{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)+  * ''%%{{count>tag1 tag2 tag3&. ns1 ns2}}%%'' -- List all occurrences for the given tags inside the namespaces (the dot ''.'' specifies the root namespace) 
 +  * ''%%{{count>+&ns1 ns2}}%%'' -- List all tags in ''ns1'' and ''ns2''.
      
 ==== Tagpage ==== ==== Tagpage ====
 +Make link to the tag list
  
    {{tagpage>[tag][&dynamic][|title]}}    {{tagpage>[tag][&dynamic][|title]}}
Line 104: Line 116:
 The plugin can be configured with the DokuWiki configuration manager available in the admin menu. 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''+^ ''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 ''%%{{topic>...}}%%'' to display the list of tags on such a page for example. The default value of ''namespace'' is: ''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''+^ ''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'' to sort pages before namespaces and ''title''
-^ ''sortorder'' | Sort order of the topic overview|+^ ''sortorder'' | Sort order of the topic overview (ascending or descending) |
 ^ ''pagelist_flags'' | Comma separated [[plugin:pagelist#Flags]] of the [[plugin:pagelist]] plugin which is used to display 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. | ^ ''toolbar_icon'' | Show icon in page editor toolbar to add tags. |
Line 117: Line 129:
  
 ===== Demo / Screenshots ===== ===== Demo / Screenshots =====
 +Topic listing:
 +{{ https://trello.com/1/cards/64398723319f190ba6cb5235/attachments/6439875fa2fed84e68e5c06e/download/tag_overview.png?recache |Tag overview}}
  
-{{ http://dump.lupo49.de/tmp/dokuwiki/plugin_screenshots/tag/tag_overview.png?283x205 }} +Tags: 
- +{{ https://trello.com/1/cards/64398723319f190ba6cb5235/attachments/64398760e3c8fe34a7786c62/download/tag_page.png?recache |A page with tags}}
-{{ http://dump.lupo49.de/tmp/dokuwiki/plugin_screenshots/tag/tag_page.png?200x58  }}+
  
 ===== Changes ===== ===== Changes =====
Line 161: Line 174:
   * [[http://pe.hillschmidt.de|Prinz Eisenherz Lexikon]] (German)   * [[http://pe.hillschmidt.de|Prinz Eisenherz Lexikon]] (German)
   * [[http://wiki.psiconauti.net|Psiconauti]] (Italian)   * [[http://wiki.psiconauti.net|Psiconauti]] (Italian)
 +  * [[https://radeff.red/blog/cloud|Blog Fred Radeff]] (French)
 +
  
  
Line 175: Line 190:
 <code> <code>
 {{tag>"tag with multiple words"}} {{tag>"tag with multiple words"}}
 +</code>
 +
 +==== How to make the tag namespace breadcrumb still work ====
 +
 +Let's use one of the example websites.
 +
 +If you go to https://wiki.psiconauti.net/tag/esperienze?do=showtag&tag=esperienze and then click in the breadcrumb "esperienze" you go to https://wiki.psiconauti.net/tag/esperienze , an empty page.
 +To make your pages inside the tag namespace always go to the tag list, add this to the beginning of your /.htaccess
 +
 +This also allows you to keep your start page to add there, for example, the list of tags
 +If your [[config:startpage|start page]] is not "start", change it to the one you use
 +
 +<code>
 +RewriteCond %{REQUEST_URI}            !tag:start
 +RewriteRule ^tag.([\-_a-zA-Z0-9\ ]*)$  tag:$1?do=showtag&tag=$1
 </code> </code>
  
Line 181: Line 211:
 This colors the background of the page to red if the keyword 'deprecated' is specified as a tag. This colors the background of the page to red if the keyword 'deprecated' is specified as a tag.
  
-<code php>+<code php action.php>
 function _handle_keywords(&$data) { function _handle_keywords(&$data) {
         global $ID;         global $ID;
Line 187: Line 217:
         // Fetch tags for the page; stop proceeding when no tags specified         // Fetch tags for the page; stop proceeding when no tags specified
         $tags = p_get_metadata($ID, 'subject', METADATA_DONT_RENDER);         $tags = p_get_metadata($ID, 'subject', METADATA_DONT_RENDER);
-        if(is_null($tags)) true;+        if(is_null($tags)) return;
                
         // Replace underscores with blanks         // Replace underscores with blanks
Line 194: Line 224:
                 $meta['content'] = str_replace('_', ' ', $meta['content']);                 $meta['content'] = str_replace('_', ' ', $meta['content']);
                                
 +                // add extra styling
                 $t = explode(',', $meta['content']);                 $t = explode(',', $meta['content']);
                 if(in_array('deprecated', $t)) {                 if(in_array('deprecated', $t)) {
Line 314: Line 345:
 } }
 </code> </code>
 +
 ==== How to change the word tag and topic to another language ==== ==== How to change the word tag and topic to another language ====
  
 > Is it possible to change the word tag used in syntax to something else, like another language <nowiki>{{tagInMylanguage>someTag}}</nowiki> --[[user>damascene]] //2012/04/10// > Is it possible to change the word tag used in syntax to something else, like another language <nowiki>{{tagInMylanguage>someTag}}</nowiki> --[[user>damascene]] //2012/04/10//
 +
 +You need to add copy of the existing tag pattern, and modify it to 
 +<code php syntax/tag.php>
 +    $this->Lexer->addSpecialPattern('\{\{tag>.*?\}\}', $mode, 'plugin_tag_tag');
 +    //e.g. Spanish:
 +    $this->Lexer->addSpecialPattern('\{\{etiqueta>.*?\}\}', $mode, 'plugin_tag_tag');
 +</code>
  
 ===== Discussion ===== ===== Discussion =====
 +
 +==== Pagelist With Alphabetical Headers ====
 +
 +Is there a way to group pages by the first letter of their name or header?
 +
 +Something like the example in this post on the user forums? https://forum.dokuwiki.org/d/12198-alphabetical-ordered-pages-list
 +> No.
 +
 +==== Collapsible outline of all tags ====
 +My ideal tag "cloud" display would have an alphabetic list of all tags. Click on a tag to expand (unfold) the display, and it would show an alphabetic list of pages that include that tag. We would want typical flags, such as for specifying namespaces, and display (like nspages), plus limiting tags (perhaps with RegEx?).\\
 +--davidtango 2021-03-21
 +
 +---
 +
 I want the description under the tag, is it possible to make a line brake or to get the description under the tag? Thx I want the description under the tag, is it possible to make a line brake or to get the description under the tag? Thx
  
Line 324: Line 377:
  
  
-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 : [[https://github.com/dokufreaks/plugin-tag/issues|Bug tracker]]. For __**bugs or feature requests, there is the bug tracker**__ linked here : [[https://github.com/dokufreaks/plugin-tag/issues|Bug tracker]].
Line 359: Line 409:
 == Nothing was found. == == Nothing was found. ==
 Same here, get a Nothing was found page. Same here, get a Nothing was found page.
-Me tooClicking a tag link gives me "Nothing was found."+ 
 +(2017-03-28) I had the same problemBy 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.
  
 == SEO meta keywords == == SEO meta keywords ==
Line 366: Line 417:
 == Sorting the {{count>}} results == == Sorting the {{count>}} results ==
 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.  --- [[user>Fabricio Rocha|Fabricio Rocha]] //2016-06-19 19:42// 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.  --- [[user>Fabricio Rocha|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
  
 == Unorderd List of all tags? == == Unorderd List of all tags? ==
 Is there a way to gen an unorderd list of all tags, similar as {{count>+}}, but without table and occurrences? Is there a way to gen an unorderd list of all tags, similar as {{count>+}}, but without table and occurrences?
 +
 +== Filtering the list of Tags? ==
 +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.
 +
 +== Add "*" to list all the tags under a tag namespace? ==
 +I need a function to add all the tags under a tag namespace to the tag list.\\
 +That is, when I have a ns1:tag1, ns1:tag2, ..., ns1:tagN, I can use <code>{{topic> ns1:*}}</code> to show all the pages with the tag under the namespace ns1. It is quite useful because sometimes I just want to show the pages with a sub tag, but sometimes I want to show all the pages with these tags on a main page. Since the tags under ns1 may be added in the future, I do not need to change the main page code to add more tags.\\
 +Now the tag namespace cannot be managed, I hope the basic function can be added.\\
 +2021-6-28
plugin/tag.1490738423.txt.gz · Last modified: 2017-03-29 00:00 by 216.66.188.62

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki