Float sticky post to the top

This commit is contained in:
Robert Miles 2019-10-08 11:29:52 -04:00
parent ed3bcb40ed
commit 1b50c7290c
1 changed files with 14 additions and 0 deletions

View File

@ -1,5 +1,19 @@
<?php
// Float pinned posts to the top.
// If they share a pinned/unpinned status, later post comes to the top.
// Otherwise, force pinned post to the top.
function pinned_sort($thread_a,$thread_b) {
if ($thread_a["pinned"]==$thread_b["pinned"]) {
return (($thread_a["created"]>$thread_b["created"])? -1 : 1);
}
if ($thread_a["pinned"]) {
return -1;
}
return 1;
}
$threads = $bbj->thread_index();
usort($threads["data"],"pinned_sort");
foreach($threads["data"] as $thread) {
$username = $threads["usermap"][$thread["author"]]["user_name"];
$last_author = $threads["usermap"][$thread["last_author"]]["user_name"];