Topic: Sort ShowNews by...
Has anyone managed to make a sort news function for the newest version?
Dear CuteNews Users! Please feel free to contact us via our new Feedback Form and please send information about bugs to our bug tracker.
You are not logged in. Please login or register.
CutePHP Forums → Problem Solving / Help & Support → Sort ShowNews by...
Has anyone managed to make a sort news function for the newest version?
Yes.
Open
core/com/allow_active_news.php
Add below
else $count_all = count($all_news);
This sort code:
// Sort News v1.1 - Start addblock
// To specify sorting, put the following in your include code:
// $sortby = X;
// Where X is a number from 0-6, which mean the following:
// 0 = sort by time
// 1 = sort by author
// 2 = sort by title
// 3 = sort by short story
// 4 = sort by long story
// 5 = sort by avatar
// 6 = sort by category
//
// To specify ascending/descending, put the following in your include code:
// $sortad = X;
// Where X is either "a" or "d"
//
// The lines below will automatically sort your news if news if the sort variables are unset
if (!isset($sortby)) { $sortby="0"; } if (!isset($sortad)) { $sortad="a"; }
// DO NOT EDIT BELOW
if (isset($sortby)) {
$every_news = $all_news;
if (!function_exists('sortcmp')) {
function sortcmp($a, $b) {
global $every_news, $sortby;
$news_a = explode('|', $every_news[$a]);
$news_b = explode('|', $every_news[$b]);
return strnatcasecmp($news_a[$sortby], $news_b[$sortby]);
}
}
uksort($all_news, 'sortcmp');
if ($sortad=="d") { $all_news = array_reverse($all_news); }
unset($sortby, $sortad);
}
// Sort News v1.1 - End addblock
But remember if you update cutenews with a newer version this this file may be overwritten and you will need to add the hack again.
CutePHP Forums → Problem Solving / Help & Support → Sort ShowNews by...
Powered by PunBB, supported by Informer Technologies, Inc.
The pun_antispam official extension is installed. Copyright © 2003–2009 PunBB.