Filters

This is a user-contributed Extra. If you find issues or would like more info or help, please contact the author.

Filters

The package includes the following filters:

Filter Description
content for filtering by site_content table fields; can be substituted by the addWhereList parameter
tv for filtering by template variables
tvd for filtering by template variables taking default values into account
private for filtering documents taking access rights into account

Filter construction

Example:

OR(AND(filter:field:operator:value;filter2:field:operator:value);(...))

Operators Description
=, eq, is Equal.
!=, no, isnot Not equal.
>, gt Greater than.
<, lt Less than.
<=, elt Equal or less than.
>=, egt Equal or greater than.
%, like Contains string.
like-r At end of string.
like-l At start of string.
regexp Selection using regular expressions Regular Expressions.
against Fulltext search.

Example:

[[DocLister? &filters=`AND(content:pagetitle,description,content,introtext:against:search string)`]]

This example assumes the database has FULLTEXT indexes for the pagetitle, description, content and introtext fields

containsOne Search for any word or part of a word using LIKE.

Example:

[[DocLister? &filters=`AND(content:content:containsOne:when,begin,peace)`]]

This will build a SQL query element thus:

(content LIKE '%when%' OR content LIKE '%begin%' OR content LIKE '%peace%')

That is, the end result will be the selection of documents where the words "when" or "begin" or "peace" are used in the text.

Is it evident from the example that the words are separated by commas. This behaviour can be defined with the filter_delimiter parameter

in Is in the set.
notin Is not in the set.

An example of a call filtering by price between 0 and 300:

[[DocLister? &filters=`AND(tv:price:gt:0;tv:price:lt:300)`]]

The same thing, but taking default values into account:

[[DocLister? &filters=`AND(tvd:price:gt:0;tvd:price:lt:300)`]]

Suggest an edit to this page.