PDA

View Full Version : Adding a thread sort option


darnoldy
03-06-2015, 02:37 AM
I want to be able to sort threads within a forum by prefix (if the forum has prefixes)?not just choose to only show threads with a particular prefix.

So, I modified the showthread template like this:
<select name="sort" id="sel_sort">
.
.
.
<if condition="$prefix_options">
<option value="prefixid" $sort[prefixid]>Region</option>
</if>
</select>but its not sorting.

So, is "prefixid" just the wrong variable, or do I need to add some code (with a plugin?) to process it?

kh99
03-06-2015, 12:22 PM
You need a simple plugin to make that work. Use hook location forumdisplay_sort and code like this:
if ($sortfield == 'prefixid')
$sqlsortfield = 'thread.prefixid';

That sorts by the prefix id and not the actual displayed text, but maybe that will work for you.

darnoldy
03-06-2015, 02:53 PM
That works just right!
When I created the prefixes, I did so in alphabetical order, so sort by id works fine.

Thank you!!