DokuWiki Tag Entry Plugin

This DokuWiki plugin provides functionality to assign tags to a wiki-page using checkboxes.

The tagentry plugin has just been released on the DokuWiki website.

About

The tagentry plugin displays a set of tag-name checkboxes just below the edit form and automatically adds or modifies {{tag>}} in the wiki-text using JavaScript when a checkbox is activated.

This plugin can be installed standalone, but makes only sense in combination with a recent version (later than summer 2008) of the tag plugin.

Setup and Configuration

There are a few configuration options available, accesible via the configuration-manager.

tagsrc choose which tags to display. The default is to display all tags known to the tag plugin's index. Alternatively you can use the IDs of existing pages in a dedicated namespace (by default the tag plugin's namespace)
namespace IFF tagsrc is set to custom; search this namespace.
table Format checkboxes using a HTML <table> instead of just pushing them into a <div>
limit Maximum number of tags to list - 0:unlimited
blacklist Space separated list of tags to hide from the assignment-bar
height specify maximum height of the box in float(em,px,pt) format.
>0: fixed value (eg. 50px); 0 or empty: use CSS; <0: scale with number of entries (fi. -1em should get you rid of the scroll-bar, -0.05em is a sane value for sites with many tags.)
tablerowcntwhen using <table> formatting, this allows to specify the number of tags per table-row. (default:5)

Note: the default max-height is currently defined in lib/plugins/tagentry/style.css as 5em.

Development Info and Discussion

ToDo:

  • style it - v0.2.3 and above include a style.css.
  • hide it or print a message if no tags are found - done in v0.2.2 <div> wrapper is still written; but the <label> will not be printed if $alltags is empty. check this when finishing layouting.
  • check already assigned tags on load (either in JavaScript or better internally when generating the edit-form) - done in v0.2.2
  • hide the form when only a part of a page is being edited (the {tag} tag may not be in it) - done v0.2.4
  • provide a mechanism to prevent a Tag from being listed, other than the configuration blacklist (use eg.META or some custom command similar to DRAFT on the Tag's -page)
  • use a flexible form-name or optionally skip the tag-list when fi. another plugin supplies the edit form (eg. discussion plugin).
  • optimize performance
  • JavaScript: handle errors more smoothly (eg. multiple '{{tag}}' tags); make alert() messages translatable or remove them.
  • move render and tag processing functions to helper.php in order to make them available for other plugins (fi. plugins:dokubookmark).
  • JavaScript: if there is a commented out {{tag}} (surrounded by double %) on a page, active tags are not selected. This is related to above ToDo item of multiple {{tag}}s per page.

As always: Comments, suggestions and patches or feedback of any kind is more than welcome. Put them here while I update the trac.


  • I have a lot of tags and the list gets ugly. When I tried to use the table option, all my tags got on one row in the table. I think it is good to add an option to set what number of tags should go into one row to create a good table. Another option could be to wrap the tags in a div and be able to set a fixed width for the divs and let them float, but this could be harder because of wrapping.

EDIT: found out the code was wrong. Line 261 should read: if ($i%$options['tablerowcnt']==0 && $i!=0) { fixed in 0.3.2 (2009-09-18) - Thanks for pointing this out.

Fact remains that I can not set the tablerowcnt from the config manager.. I've added that to the config manager, as well.

Answer: As for your alternative approach: You can already make the checkboxes float. They're wrapped in a <label> environment which allows for width and float CSS paramters.

The CSS would look like this:

#plugin__tagentry_wrapper div.taglist label {
  width: 50px;
  overflow: hidden;
  float:left;
}

I'm having a devil of a time configuring tagentry. What I desire is to limit what tags are listed by the namespace. Take the following example of namespaces:

namespace1:page1 namespace1:page2 namespace2:page1

When creating or editing pages in namespace1, I only want to display the tags specific to that namespace. I am unsure how to configure the tagentry plugin to do this. Up to this point the only way I get any tagentry checkboxes to display is to configure “Select which tags will be available” to “All tags” otherwise no checkboxes are displayed.

Answer: This is beyond the capabilities of this plugin. The feature you are requesting would require support from the tag plugin itself to group tags by namespace.

The tagentry-namespace configuration option is there for backwards compatibility with the old tag-plugin, which created pages in a specific namespace for each tag. The latest version of the tag-plugin still supports this, but does not create the pages automatically.

PS. There's is already a feature-request on http://www.dokuwiki.org/plugin%3Atag#limit_tag_list_by_namespace for that purpose.


  • The following error is showed if there is no tag created yet.

Warning: Invalid argument supplied for foreach() in [wiki path]/lib/plugins/tagentry/action.php on line 170

Answer: That was a bug which occurred if there are were no tags defined on the system. - Cheers for reporting this.


  • What exactly does this access when it lists the tags? I'm using this plugin, but it doesn't display every tag that I have and it displays some older tags that I no longer use. Also, is it possible to display the tags without the scrollbars?

A: per default it uses the tag plugin's topic.idx. Rebuild your tag index (available from Admin menu) to clean out old tags.

long Answer: Older versions of the tag-plugin required to create wiki pages for each tag, later versions use a '?do=showtag' action. The new version displays the page with the tag-name if it exists and else generates a topic listing.
Maybe you have older tags still sitting around as pages?

As for the scrollbar: there is no configuration option for that yet. You can edit lib/tpl/tagentry/style.css and adjust or remove the max-height parameter. You can also override it in your site's template. The number of tags per line is also still fixed and hardcoded to five. Well, this plugin's barely 3 days old; but we'll get there. set the height configuration option (available from v0.2.5 or later) to -1em. That adds one line per displayed tag to the max-height style parameter of the box. Horizontal scrolling - related to limiting the displayed tag-name - will be made configurable in a later version.


  • There are several deprecated use of references in the Php code :-\ . It will not work with next versions of Php :-( .It works today but generate many Warnings like : ”Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in /home/dokuwiki-2008-05-05/lib/plugins/tagentry/action.php on line 75

Fixed in version 0.3.0 (2009-01-30).


  • I got the Problem, that the Plugin do not alter or add the Taglist. If I alter the list in the text manually, next time the plugin recognizes that the tag are already in the list, but nothing more.

That sounds like the javascript of the plugin is not loaded or you've disabled Javascript in your browser. Try to flush the cache:

  • DokuWiki cache: `touch conf/dokuwiki.php`
  • if you're running php-xcache: restart your web-server or use the xcache admin interface to clear it
  • shift+reload the page to flush your browser cache.

It worked, thx a lot!


  • A very simple question: is there a recommended height or action for a wiki with a high number of tags? (have tried but got confused and have no knowledge of CSS :-\ ) We'd like them to come up with a scroll bar or table?

Scrollbars are already automatically added if there's more than 6 lines of tags. The style.css defines:

overflow:auto;
max-height:6em;

Simply modify the 'max-height' parameter (in …/lib/plugins/tagentry/style.css) with a text-editor to your preferences (eg. max-height:40px; )

Note: older versions of IE do not support max-height! Use height:6em;, but then the box will then always be fixed at this height and never shrink.


  • Add Opera support – what's broken?? It works fine; I've just tested with opera 9.63. Maybe you have disabled JavaScript (Tools → Preferences → Content → enable JavaScript)

Resources

This plugin inspired by dokubookmark, generalizing the idea of graphically assigning tags on page-creation.

see also:

 
wiki/tagentry.txt · Last modified: 18.09.2009 12:13 by rgareus
   |