Additional sort opt...
 
Notifications
Clear all

Additional sort options for browse.php/header.php

8 Posts
3 Users
0 Likes
1,426 Views
(@walterhpdx)
Posts: 5
Active Member
Topic starter
 

I've got a user who wanted an eFiction site, so I installed it for her.  The default options for "browse.php" aren't enough - simply just "Alphabetical" and "Newest to Oldest".  I've been fighting with code most of the day, and can't get it to honor additional sort options.  My other requested options are: "Oldest to Newest", "Word Count (longest to shortest)", and "Word Count (shortest to longest)".  Has anyone done this successfully (or any other mod to add an additional sort options) that I can look at, to base my own work on?

The site is running eFiction 3.5.2 on Linux/mySQL.

Thanks

Walter

 
Posted : 11/10/2010 5:20 pm
(@lyndsie)
Posts: 1262
Member Moderator
 

Browse by word count: https://efiction.org/forums/index.php?topic=7241.0

Check out the list of mods: https://efiction.org/wiki/index.php5?title=Mod_List

You should also upgrade to 3.5.3 as it has several bug fixes for 3.5.2.

 
Posted : 11/10/2010 5:41 pm
(@walterhpdx)
Posts: 5
Active Member
Topic starter
 

Browse by word count's not the same as sort by word count, though we did consider it.  I did check out the list of mods, and don't see anything that's remotely close to what we need.

 
Posted : 11/10/2010 5:58 pm
(@lyndsie)
Posts: 1262
Member Moderator
 

Are you sure? The mod adds additional sort options (max and min word count) to browse.php. Unless you are talking about the Default Story Sort setting for user profiles?

 
Posted : 11/10/2010 7:44 pm
(@walterhpdx)
Posts: 5
Active Member
Topic starter
 

If you look at the example from the post: https://efiction.org/forums/index.php?topic=7241.0

You can search by minimum and maximum words.  When you do, the stories are either in alphabetical or most-recent order.  That's not what I'm looking for.  I'm looking for alphabetical, newest to oldest, oldest to newest, shortest to longest, and longest to shortest.  Their example lists stories between two different sizes, but does not allow you to sort on those sizes.

Specifically, I know that it is this code that controls it:

if(isset($_REQUEST['sort'])) $defaultsort = $_REQUEST['sort'] == "update" ? 1 : 0;
define("_ORDERBY", " ORDER BY ".($defaultsort == 1 ? "updated DESC" : "stories.title ASC"));

And I know how this works -- I just don't know how to turn this from 2 options to 5 options.  If I change "updated DESC" to "wordcount DESC" or "wordcount ASC", it will do my sorting properly.  But like I said, I need all 5 options, not just these two.

 
Posted : 11/10/2010 8:57 pm
(@lyndsie)
Posts: 1262
Member Moderator
 

There are a couple of things at work. You have to change the form to include the additional options. Then you have to update the part of browse.php (or wherever you pulled the code from) to define the action you want from each option. There is actually a field for wordcount in fanfiction_stories so really it probably would work if you you simply replaced title with wordcount in the last part of that code.

 
Posted : 12/10/2010 2:28 am
(@walterhpdx)
Posts: 5
Active Member
Topic starter
 

My basic problem was that the default code (alphabetical or date sort) is written like "TRUE/FALSE" in PHP, which was why it was making me so crazy all day today.  I'm not a PHP programmer, but am definitely a PHP hacker.  At least I understand now why it wouldn't work.

I ended up outsourcing this to a Canadian PHP programmer, and he modified the code in browse.php to include the additional search elements, and then created an array in header.php to handle the actual sorting.  Works like charm!  And now that I understand it, it'll make it that much easier for future mods.  If people are interested enough, I could post the mod here (or wherever it's supposed to be done).

 
Posted : 12/10/2010 4:39 am
(@jacynthe)
Posts: 242
Estimable Member
 

I would definitely be interested in that as I've been thinking I needed more options to sort the stories myself and like you, I am in no way a programmer. Heck, I'm not much of a coder, period. LOL My chances of breaking something are greater than my chances of fixing stuff. LOL

Jacynthe

Archives: http://fanfics.e-authors.net
Version: 3.5.3
Modified? Somewhat...
PHP:  5.3.3
MySQL: 5.0.91-community

 
Posted : 17/10/2010 2:37 am
Share: