Latest Register Log In

+ Advanced Search

Filters

Filters
By
07/14/04 (Edited 12/15/14)

Filters allow people to thin the display to only articles which meet specific criteria. For numeric fields it will (by default) filter to where the value is greater than or equal to the one of that article. For text fields it will filter to where the value is exactly the same.

To allow people to filter by a field value of a particular article, use <a href="{LINKFILTERLINK[fieldname]}">Filter to {LINKFIELDNAME}</a> in your template. For example, to filter by number of posts use <a href="{LINKFILTERLINK[numposts]}"><IF {LINKHASFILTER[numposts]}>Remove number of posts filter<ELSE>Filter to {LINKNUMCOMMENTS}+ posts</IF></a>.

You can also add a custom filter (not tied to a particular article's values) with a simple text link by using <a href="{FUNC_FILTERLINK[catid <,> field <,> value]}">Apply Filter</a>. Replace catid with the forum id number (or if you're in an applicable spot like the show articles in forum template you can use {CATID} -- the user will be redirected to the specified forum on clicking), field with the field name and value with the value to filter to... for example, <a href="{FUNC_FILTERLINK[1 <,> numposts <,> 5]}">View threads from forum #1 that have 5 or more posts</a>

Often you'll want o make a form with a selector, instead of a link. Here's an example of how to do that:
<form action="index.php?action=displaycat&catid={CATID}&filter=numposts&linkfilteraction=add" method="post">
Show threads with at least
<select name="filtervalue">
<option value="removefilter">show all</option>
<option value="1">1</option>
<option value="5">5</option>
<option value="10">10</option>
</select> post(s). <button type="submit" class="gobutton">Filter</button>
</form>

Place that anywhere you want it -- for example, in the "show articles in forum" template or the "front page" template. Note that the filter will apply to all forums and searches viewed, until removed.

Note that you can make numeric filters filter to <= instead of >= by using a filtertype=less parameter in a url. To filter between two numeric values, use filtertype=between and a second input for the max value named filtervaluemax / forumfiltervaluesmax[x]. To filter to any text that contains a term, use filtertype=contains. To filter to any text that is not equal to the specified text, use filtertype=not. You can pass the filter type as the second parameter to {LINKFILTERLINK}, like {LINKFILTERLINK[descripton <,> contains]}. It can also be passed to {FILTERLINK} as the third parameter, like {FILTERLINK[1 <,> description <,> contains]}.

Filters remain in place for a day with a cookie unless removed. To remove a filter you can use filtervalue=removefilter, and to remove all filters at once you can use filtervalue=removefilters.

To retrieve the current value of a particular filter for display, use {FUNC_FILTERVALUE[fieldname]} for topic filters or {FUNC_FILTERVALUE[fieldname <,> post]} for post filters.

To list all current filters, with a removal link next to them, use this code in the display topics in forum template:
<IF {FUNC_USINGFILTERS}>
Current filters<br>
<!-- BEGIN FILTERS -->
{FILTERFIELD} {FILTERTYPE} {FILTERVALUE} [<a href="{FILTERREMOVEURL}">x</a>]<br>
<!-- END FILTERS -->
</IF>


Forum-Specific, Non-Stick Filters

Sometimes you may want to do a filter in the way as the sorting -- so it's just for the current view. You may want all the filters to be set in the same form with one button, or set by the sort button. You can do this. Here's an example which merges a couple of filters with the sorting area in the 'sort articles' subtemplate:

<IF {SWITCH_SORTLINKS} and {CATLINKSHERE}>
<div class="sort">
<form action="index.php">
<input type="hidden" name="todo" value="orderlinks" >
<input type="hidden" name="action" value="displaycat" >
<input type="hidden" name="catid" value="{CATID}" >
Filter
<select name="perpage">
<option value="{PERPAGE}">{PERPAGE}</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
</select>
articles per page, which match
<input type="hidden" name="forumfiltersfields[0]" value="program_type" >
<input type="hidden" name="forumfiltersfields[1]" value="program_os_support" >
<input type="hidden" name="forumfilterstypes[0]" value="=" >
<input type="hidden" name="forumfilterstypes[1]" value="LIKE" >
<select name="forumfiltersvalues[0]"><option value="">License Type</option><option value="Shareware">Shareware</option><option value="Freeware">Freeware</option><option value="Adware">Adware</option><option value="Demo">Demo</option><option value="Commercial">Commercial</option><option value="Data Only">Data Only</option></select>
<select name="forumfiltersvalues[1]">
<option value="">Operating System</option>
<option value="Android">Android</option>
<option value="BlackBerry">BlackBerry</option>
<option value="Handheld/Mobile Other">Handheld/Mobile Other</option>
<option value="iPhone">iPhone</option>
<option value="iPod">iPod</option>
<option value="Linux">Linux</option>
<option value="Mac OS X">Mac OS X</option>
<option value="Mac Other">Mac Other</option>
<option value="MS-DOS">MS-DOS</option>
<option value="Unix">Unix</option>
<option value="Win2000">Windows 2000</option>
<option value="Win7 x32">Windows 7 (32 bit)</option>
<option value="Win7 x64">Windows 7 (64 bit)</option>
<option value="Win98">Windows '98</option>
<option value="WinMobile">Windows Mobile</option>
<option value="WinOther">Windows (other)</option>
<option value="WinServer">Windows Server</option>
<option value="WinVista">Windows Vista</option>
<option value="WinVista x64">Windows Vista (64 bit)</option>
<option value="WinXP">Windows XP</option>
<option value="Other">Other</option>
<option value="Not Applicable">Not Applicable</option>
</select>
ordered by
<select name="orderlinks">
<option value="id">newest</option>
<option value="lastedit">last edited</option>
<option value="title">title</option>
<IF {SWITCH_RATINGS}>
<option value="rating">rating</option>
<option value="votes">votes</option>
</IF>
<IF {SWITCH_HITS}><option value="hits">views</option></IF>
<IF {SWITCH_HITSIN}><option value="hitsin">incoming clicks</option></IF>
<IF {SWITCH_COMMENTS}><option value="numposts">posts</option></IF>
<IF {SWITCH_PAGERANK}><option value="pagerank">PageRank</option></IF>
</select>
<select name="ascdesc">
<option value="ASC">ascending</option>
<option value="DESC">descending</option>
</select>
<button type="submit" class="gobutton">Sort</button>
</form>
</div>
</IF>


Post Filtering

In addition to articles, you can also filter posts -- the thread will be filtered to only display posts matching the criteria. Posts filters work the same as article filters except with COMMENT in place of LINK.

For posts, there's a special compound filter {COMMENTFILTERLINK[approved / votes]} which is useful for filtering to posts that have at least as high of an approval percentage as the current post.

Alternatively, you can compose a direct link to apply a filter like this: <a href="posts.php?id={LINKID}&postfilteraction=add&filter=postername&filtervalue=Paul&filtertype=contains">Filter thread to Paul's posts</a>

Or if you prefer a form, use
<form action="posts.php?id={LINKID}&postfilteraction=add&filtertype=contains&filter=postername" method="post">
Show posts by
<select name="filtervalue">
<option value="removefilter">show all</option>
<option value="John Doe">John Doe</option>
<option value="Jane Doe">Jane Doe</option>
</select> <button type="submit" class="gobutton">Filter</button>
</form>




Description How to let your visitors filter the display of articles or posts.
Rating
Views 6121 views. Averaging 1 view per day.