Description: Adds two dropdown boxes to browse pages that allow sorting results by max and min word counts.
Requirements: 3.5.1. (Not tested with earlier versions.)
Download Link: http://www.verilyviridian.com/downloads/browse.zip or
http://www.verilyviridian.com/efic/browse-by-word-count/
Example: http://www.dracoandginny.com/browse.php?type=categories&catid=2
History: Published 28 July 2009.
The quickest and easiest thing to do would be to download the zip I provided and follow the instructions in the readme. However, if you've modified your browse.php, here are instructions.
Before making any changes, make sure to backup your existing files.
Open browse.php.
There is a section of code that needs to be updated. What already exists in browse.php doesnβt work unless itβs replaced by the same but slightly-different code from search.php.
At around line 186 you should find the following.
// Begin story length
unset($wordcount);
$wordlow = isset($_REQUEST['wordlow']) ? $_REQUEST['wordlow'] : "-500";
$wordhigh = isset($_REQUEST['wordhigh']) ? $_REQUEST['wordhigh'] : "1000000";
if($wordlow != "-500") $wordcount = "stories.wordcount > ".$wordlow;
if($wordhigh != "1000000")
{
if($wordcount) $wordcount .= " AND stories.wordcount < ".$wordhigh;
else $wordcount = "stories.wordcount < ".$wordhigh;
}
if($wordhigh < $wordlow) $wordcount = "stories.wordcount < ".$wordlow;
if($wordlow != "-500" && $wordhigh != "1000000" && isset($_POST['submit'])) {
$query[] = "($wordcount)";
$countquery[] = "($wordcount)";
}
// End wordcount
Replace with this:
// Begin story length
unset($wordcount);
$wordlow = isset($_REQUEST['wordlow']) && isNumber($_REQUEST['wordlow']) ? $_REQUEST['wordlow'] : "-500";
$wordhigh = isset($_REQUEST['wordhigh']) && isNumber($_REQUEST['wordhigh']) ? $_REQUEST['wordhigh'] : "1000000";
if($wordlow != "-500") $wordcount = "stories.wordcount > ".$wordlow;
if($wordhigh != "1000000")
{
if($wordcount) $wordcount .= " AND stories.wordcount < ".$wordhigh;
else $wordcount = "stories.wordcount < ".$wordhigh;
}
if($wordhigh < $wordlow) $wordcount = "stories.wordcount < ".$wordlow;
if(!empty($wordcount)) {
$query[] = "($wordcount)";
$countquery[] = "($wordcount)";
}
// End wordcount
At around line 308, add the following (this adds the dropdown menus with the others).
if(!in_array("wordcount", $disablesorts))
$wordcountmenu1 = "<select class="textbox" name="wordlow">n<option>Min words</option><option value='-500'>< 500</option>n<option>1000</option>n<option>5000</option>n<option>10000</option>n<option>50000</option>n<option>100000</option>n<option value='1000000'>100000+</option></select> -";
$wordcountmenu2 = "<select class="textbox" name="wordhigh">n<option>Max words</option><option value='1000000'>100000+</option>n<option>100000</option>n<option>50000</option>n<option>10000</option>n<option>5000</option>n<option>1000</option>n<option value='-500'>< 500</option></select>";
$tpl->assign("wordcountmenu1", $wordcountmenu1);
$tpl->assign("wordcountmenu2", $wordcountmenu2);
Save and upload browse.php.
Lastly, the variables {wordcountmenu1} and {wordcountmenu2} need to be added to any browse.tpl skin files. Note that not all skins have a browse.tpl. Here is an example of a modified browse.tpl from default_tpls.
<!-- INCLUDE BLOCK : header -->
{output}{otherresults}
<!-- START BLOCK : sortform -->
<div id="sortform">{sortbegin}{categorymenu} {charactermenu1} {charactermenu2} {pairingsmenu} {ratingmenu} {classmenu} {sortmenu} {completemenu} {wordcountmenu1} {wordcountmenu2} {sortend}</div>
<!-- END BLOCK : sortform -->
<!-- INCLUDE BLOCK : listings -->
<!-- INCLUDE BLOCK : footer -->
This is cool. Thanks, Lyndsie!
archive:
site:
Available for skin/mod commission! π
