Browse by word count
Description: Adds two dropdown boxes to browse pages that allow sorting results by max and min word counts. I have provided a download to replace the necessary file. If you have modified your browse.php, I have included line-by-line instructions below.
Version: 1.0
Compatibility: eFiction 3.5.1
Example: http://www.dracoandginny.com/browse.php?type=categories&catid=2
Download: http://www.verilyviridian.com/downloads/browse.zip
Line by Line
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 it 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).
Unfortunately there’s some kind of issue with WordPress with the code tags shifting around to wherever they choose instead of where I’d put them, so I can’t show the code here for the moment. However, it’s lines 309-314 in the download. I’ll try to get this resolved as soon as possible.
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.
Same problem again with the code tags, thus the includes are being stripped. Again, see the download. Sorry. : (
Published 28 July 2009.