Frontend User Listing sorting in reverse order
Posted: Thu Aug 09, 2007 3:42 pm
With a small change in the Frontend User Listing module, the sorting of a column can be done in reversed order. This is done by putting a minus in front of the name. Like:
{cms_module module=FrontEndUserListing group=usergroup sortkey=-date}
The code of the new function:
{cms_module module=FrontEndUserListing group=usergroup sortkey=-date}
The code of the new function:
Code: Select all
function DoUserSort ($array, $sortkey)
{
if(is_array($array) && count($array)> 0)
{
$reverse=false;
if($sortkey[0]=='-'){$reverse=true; $sortkey=substr($sortkey,1);}
// add userid index
foreach ($array as $key => $value)
{
$array[$key]['userid'] = $key;
}
foreach(array_keys($array) as $key)
{
$temp[$key] = $array[$key][$sortkey];
}
asort($temp);
foreach(array_keys($temp) as $key)
{
$sorted[] = $array[$key];
}
if($reverse) return array_reverse($sorted);
return $sorted;
}
return $array;
}