DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:tagfilter

TagFilter Plugin

Compatible with DokuWiki

  • 2017-02-19 "Frusterick Manners" unknown
  • 2016-06-26 "Elenor Of Tsort" unknown
  • 2015-08-10 "Detritus" unknown
  • 2014-09-29 "Hrun" yes

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

Last updated on
2013-11-27
Provides
Syntax, Helper, Action
Repository
Source
Requires
pagelist, tag

Tagged with ajax, filter, tags

By lisps

Installation

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

Install the plugin using the Plugin Manager and the download URL above, which points to latest version of the plugin. Refer to Plugins on how to install plugins manually.

:!: New code is there: The author wrote new code to source repo, but has not release it here. The new code FIXES some bugs mentioned below by users. As of 19 Jun 2016, the newest code is of 3 Apr 2014, but it might be buggy in UI. Instead, code of 2 Apr 2014 is recommended, the URL of code's zip can be pasted in Manual Install of Extension Manager.

Examples/Usage

{{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}}

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
    • cache=<seconds> optional caching time
    • 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

Change Log

  • 2013-10-25
    • Initial release
  • 2013-11-27
    • add some performance improvements
    • add cache option
    • remember selected tags on browser back-action

Known Bugs and Issues

ToDo/Wish List

FAQ

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

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: 2017-11-01 17:03 by 162.248.233.99