You need again replace manage.php, download and replace attached file
Then in your existing plugin file admin_manage_build_page.php
Code:
// Add new item to sort array
$filter_array[] = 'Rank';
// extend the security checks, used in the pagination and query to get members
if (!empty($FORM['filter']))
{
switch ($FORM['filter'])
{
case 'Rank': $filter = $this->rank_by($CONF['ranking_method'])." {$order}, unq_{$CONF['ranking_method']}_overall"; break;
// The default $filter = $filter is what we already defined before this plugin hook
default: $filter = $filter; break;
}
}
You may notice, we only set a sinlg extra filter for ranks, that is because in order to rank by category, you actually need to search for the category, as the category rank is nothing stored in database
Now in the same plugin setup a new file called admin_manage_extend_search.php
in there paste
Code:
if (preg_match('/^category\s(.+)/i', $FORM['search'], $matches))
{
if (isset($matches[1]))
{
$search_name = htmlspecialchars($matches[0], ENT_QUOTES, "UTF-8");
$search_name_sql = $DB->escape($matches[1], 1);
$search_sql = "AND category = '{$search_name_sql}'";
}
}
Now how things work?
- You select from filter the option rank.If you leave the search field empty, it ranks by overall rank
- to rank by category, you actually need to fetch the category, that's why we extended the search
You need again select rank, but additionally insert into the search field "category my category name"
Its important that you write category itself before your actual category name so the default search is not triggered
This is a bit complicated, but no other way, as again you cannot sort your list without having the category name at hand, that's why we search for it.