[MOD] Browse by wor...
 
Notifications
Clear all

[MOD] Browse by word count

2 Posts
2 Users
0 Reactions
2,423 Views
(@lyndsie)
Posts: 1263
Member Moderator
Topic starter
 

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'>&lt; 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'>&lt; 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 -->

 
Posted : 30/07/2009 2:19 am
 Elle
(@jenny)
Posts: 594
Honorable Member
 

This is cool. Thanks, Lyndsie!


archive: dramione.org
site: accio.nu

Available for skin/mod commission! πŸ™‚

 
Posted : 30/07/2009 12:20 pm
Share: