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 comments use <a href="{LINKFILTERLINK[numcomments]}"><IF {LINKHASFILTER[numcomments]}>Remove number of comments filter<ELSE>Filter to {LINKNUMCOMMENTS}+ comments</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 category id number (or if you're in an applicable spot like the show articles in category template you can use {CATID} -- the user will be redirected to the specified category on clicking), field with the field name and value with the value to filter to... for example, <a href="{FUNC_FILTERLINK[1 <,> numcomments <,> 5]}">View threads from category #1 that have 5 or more comments</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=numcomments&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> comment(s). <button type="submit" class="gobutton">Filter</button>
</form>
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> comment(s). <button type="submit" class="gobutton">Filter</button>
</form>
Place that anywhere you want it -- for example, in the "show articles in category" template or the "front page" template. Note that the filter will apply to all categories 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 / categoryfiltervaluesmax[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 article filters or {FUNC_FILTERVALUE[fieldname <,> comment]} for comment filters.
To list all current filters, with a removal link next to them, use this code in the display articles in category template:
<IF {FUNC_USINGFILTERS}>
Current filters<br>
<!-- BEGIN FILTERS -->
{FILTERFIELD} {FILTERTYPE} {FILTERVALUE} [<a href="{FILTERREMOVEURL}">x</a>]<br>
<!-- END FILTERS -->
</IF>
Current filters<br>
<!-- BEGIN FILTERS -->
{FILTERFIELD} {FILTERTYPE} {FILTERVALUE} [<a href="{FILTERREMOVEURL}">x</a>]<br>
<!-- END FILTERS -->
</IF>
Category-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="categoryfiltersfields[0]" value="program_type" >
<input type="hidden" name="categoryfiltersfields[1]" value="program_os_support" >
<input type="hidden" name="categoryfilterstypes[0]" value="=" >
<input type="hidden" name="categoryfilterstypes[1]" value="LIKE" >
<select name="categoryfiltersvalues[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="categoryfiltersvalues[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="numcomments">comments</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>
Comment Filtering
In addition to articles, you can also filter comments -- the thread will be filtered to only display comments matching the criteria. Comments filters work the same as article filters except with COMMENT in place of LINK.
For comments, there's a special compound filter {COMMENTFILTERLINK[approved / votes]} which is useful for filtering to comments that have at least as high of an approval percentage as the current comment.
Alternatively, you can compose a direct link to apply a filter like this: <a href="comments.php?id={LINKID}&commentfilteraction=add&filter=postername&filtervalue=Paul&filtertype=contains">Filter thread to Paul's posts</a>
Or if you prefer a form, use
<form action="comments.php?id={LINKID}&commentfilteraction=add&filtertype=contains&filter=postername" method="post">
Show comments 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>
Show comments 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>