DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:tagfilter

TagFilter Plugin

Compatible with DokuWiki

  • 2018-04-22 "Greebo" yes
  • 2017-02-19 "Frusterick Manners" yes
  • 2016-06-26 "Elenor Of Tsort" yes
  • 2015-08-10 "Detritus" yes

plugin Allows to create custom dropdown fields to easily filter pages based on tags

Last updated on
2018-10-04
Provides
Syntax, Helper, Action
Repository
Source
Requires
pagelist, tag

Tagged with ajax, filter, tags

Installation

:!: External requirements: This plugin requires the following additional components that must be installed separately:

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

:!: New code is there: I fixed the download url, please update.

Examples/Usage

Expecting you have several pages with different tags, defined by tag plugin. In the following examples we have two pages

  • Page 1 {{tag>status:ready version:weatherwax}}
  • Page 2 {{tag>status:start version:Angua}}
{{tagfilter>Status=status:.*=status:ready|Version=version:.*&nouser&nodate}}

{{tagfilter>Status=status:.*=status:ready|Version=version:.*&nouser&nodate&multi}}

{{tagfilter>Status=status:.*=status:ready|Version=version:.*&nouser&nodate&chosen}}

{{tagfilter>Status=status:.*=status:ready|Version=version:.*&nouser&nodate&multi&chosen}}

NEW TAGCOMPARE

Use tagcompare to compare tags between pages. You can select the page in columns and for each tag expression there will be a row.

{{tagcompare>Status=status:.*=status:ready|Version=version:.*}}

Example Link

Syntax

Basic syntax:

{{tagfilter>(namespace)?(tags-filter-groups)&(flags)}}
  • (namespace) defines the namespace of the filtered pages
  • (tags-filter-groups) defines the different dropdown fields: Syntax (Label)=(RegExpr)=(Standard) seperated by a |
    • (Label) the dropdown-field label
    • (RegExpr) a regular expression with which you can select the options for the select
    • (Standard) a standard value to be selected
  • (flags)
    • multi enables multiselect of tags
    • chosen enables the chosen plugin for tag searching
    • tagimage show image next to tagname in dropdown boxes. Needs chosen tag. If image is status:a image needs to be tags:status_a.[png|jpg|gif|jpeg]. Namespace tags (where the images needs to be placed) is a admin setting (nsTagImage)
    • pagesearch add an extra dropdown field at the beginning to search for the page itself.
    • rsort enable revers sort of pages
    • nolabels do not show labels
    • noneonclear show no pages when nothing is selected
    • excludeNs=<comma seperated list of namespaces> exclude specific namespaces
    • withTags=<comma seperated list of tags> these tags must be present on all pages
    • excludeTags=<comma seperated list of tags> these tags must not be present on all pages
    • count show the numbers of found pages
    • tagcolumn=<tagexpr> show an additional column in pagelist reslut with the selected tags of the page (e.g. status:.*)
    • tagimagecolumn=<tagexpr>=<imagenamespace> show an additional column in pagelist result with an image defined through the tag. (e.g. with &tagimagecolumn=status.*=tags and the page has version:example as a tag, the image tags:example.[png|jpg|gif] will be used)
    • pagelist flags

Configuration and Settings

Admin Configuration

Option Description
cache_age How long should pages with tagfilter be cached (in seconds), 0 for no caching
DropDownList_size Number of items to show in classic multiple dropdown mode

Known Bugs and Issues

ToDo/Wish List

FAQ

Development

Change Log

Build Status

Discussion

Set header title?

Is it possible to specify the header to be something other than “tagfilter”?

Make multi search AND instead of OR

Is it possible to have the multi search be AND instead of OR?
IE, I have the following tagfilter on a page

{{tagfilter>Type=tag:typ\..*|Ethnicity=tag:eth\..*|Ingredients=tag:ing\..*&chosen&multi}}

I want to be able to select specific ingredients and only see recipes that include ALL those ingredients. Also, even though I'm using chosen, I am still getting a dropdown menu instead of a search box.

This documentation needs some serious improvement, it's not clear at all what this plugin does and how.

Can you say where exactly your problem is?
First, the plugin heavily relies on the tag plugin.
To give an example: lets say you have the three pages
task:task1

==== Task1 ====
{{tag>version:v1 status:done year:2013}}


and task:task2

==== Task1 ====
{{tag>version:v2 status:open year:2013}}


and task:task3

==== Task1 ====
{{tag>version:v3 status:open year:2014}}


and define the tagfilter as followed

{{tagfilter>task:?Status=status:.*=status:open|Version=version:.*|Year=year:.*}} 


now you can filter the three pages with the version, status and year tags (where the tag status:open is set on page load)

I think the use of tags that have colons in your examples are confusing (to me, a noob anyway). I first was confused because I thought the colons had something to do with DokuWiki page syntax. I use a dash so my tag examples would look like: version-v3 status-open, etc.

And so my code would look like
{{tagfilter>task:?Status=status-.*=status-open|Version=version-.*|Year=year-.*}} 


.. which brings me to my question & comment, which is where does a noob find the explanation of the dot (.) before the asterisk (*) syntax? .. And,

As I described in the documentation it is a Regular Expression.

I'm afraid I have to agree that the documentation needs improvement. First you need a clear opening statement as to what the plugin does. Then you should have a list of the options and flags with clear statements about how each works. Then after explaining the options and flags give your examples.— Myron TurnerMyron Turner
turnermm

2015-12-18 12:39
I come back to this three years later, because of a question someone had on the forum, and I find that the documentation still is not clear enough. This looks like it could be useful but it shouldn't be a struggle to learn how to use it. For improvements I refer to my previous comment. — Myron TurnerMyron Turner
turnermm

2018-10-17 17:58

Can you please provide an update for the latest DokuWiki release?

Is it possible to do a count of the returned pages?

Not in this version, but feel free to open a request on github - with a description how you would like to have it implemented and with example images.

Which plugin is the 'chosen' one?

Thanks for the great plugin!

I have trouble understanding the following instruction:

chosen enables the chosen plugin for tag searching

Where have I chosen a plugin? Is it the “tagfilter” plugin? Or is “chosen” the name of another plugin, and where can I find it?

Apart from that, is it possible to apply 'chosen' and 'multi' only to some of the search field, not all?

Answer:
chosen enables the so called Chosen Plugin, which is delivered within the tagfilter plugin. Actually it is not possible to set separate select fields as multi or chosen.

About RegExp support

How can I set a filter showing only certain tags ? For example, I've tried to make a filter combo showing only *HowTo* and *Faq* tags. The regexp for that would be

Filter=(howto|faq)

But that's not working. The page shows 'faq' as another filter… How could make it work ?

as | is the seperator for the different filters it is not possible with this version of tagfilter. Possibilities:

  1. rename your tags to page:howto and page:faq and work with filter Filter=page:.*
  2. change the separator in syntax.php

No search results

How to debug why I get no search results? I added the following line to show all tags. However, bevore and after selecting one entry, no search results are shown.

{{tagfilter>Hersteller=.*=&nouser&nodate&multi&chosen}}

What is wrong?

EDIT: I looked a bit around in the PHP Files and found, that adding the following line in ajax.php gives me a somehow running solution. I am not sure about the Namespaces, but I get results…

ajax.php
$page_names = array();
foreach($tag_list_r as $key=>$tag_list){ 
	$tags_parsed = $Htag->_parseTagList($tag_list, true);
	$pages_lookup = $Htag->_tagIndexLookup($tags_parsed);
	foreach($pages_lookup as  $page_lookup){
		// filter by namespace, root namespace is identified with a dot // root namespace is specified, discard all pages who lay outside the root namespace
		if(($ns == '.' && (getNS($page_lookup) == false)) || ($ns && (strpos(':'.getNS($page_lookup).':', ':'.$ns.':') === 0))) {
			$perm = auth_quickaclcheck($page_lookup);
            if (!($perm < AUTH_READ))
				$page_names[$key][] = $page_lookup;
		}
		$page_names[$key][] = $page_lookup; // This line was added +++++++++++++++++++++
	}
}
Thanks for sharing, but your code seems bypass the ACL check, which might have security issue. The official new code's link was added in Installation section, which fixes the bug you mentioned to some degree, allowing you to filter tags without specifying namespace. But it still can not specify the root namespace, see this issue.
plugin/tagfilter.txt · Last modified: 2018-10-21 10:08 by peterfromearth