FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » Changing the Order of Topics
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Changing the Order of Topics [message #166930] Sat, 31 March 2012 10:26
bbnewbie is currently offline  bbnewbie   
Messages: 27
Registered: December 2011
Karma:
Junior Member
My goal is to have the topics displayed by the date the topic started, not by the date the thread was updated. I found an old thread that got me most of the way there, but I'd love some help on specifically what code to change to reroder based on the topic creation date rather than the last updated message date


http://fudforum.org/forum/index.php?t=msg&goto=38695&&srch=chan ging+the+order+of+topics#msg_38695

I know the code is here if anyone can help out. Thanks!


function th_new_rebuild($forum_id, $th, $sticky)
{
if (__th_cron_emu($forum_id)) {
return;
}

if (!db_locked()) {
$ll = 1;
db_lock('{SQL_TABLE_PREFIX}tv_'. $forum_id .' WRITE');
}

list($max,$iss) = db_saq(q_limit('SELECT /* USE MASTER */ seq, iss FROM {SQL_TABLE_PREFIX}tv_'. $forum_id .' ORDER BY seq ASC', 1));
if ((!$sticky && $iss) || $iss >= Cool { /* Sub-optimal case, non-sticky topic and thre are stickies in the forum. */
/* Find oldest sticky message. */
if ($sticky && $iss >= Cool {
$iss = q_singleval(q_limit('SELECT /* USE MASTER */ seq FROM {SQL_TABLE_PREFIX}tv_'. $forum_id .' WHERE seq>'. ($max - 50) .' AND iss>=8 ORDER BY seq ASC', 1));
} else {
$iss = q_singleval(q_limit('SELECT /* USE MASTER */ seq FROM {SQL_TABLE_PREFIX}tv_'. $forum_id .' WHERE seq>'. ($max - 50) .' AND iss>0 ORDER BY seq ASC', 1));
}
/* Move all stickies up one. */
q('UPDATE {SQL_TABLE_PREFIX}tv_'. $forum_id .' SET seq=seq+1 WHERE seq>='. $iss);
/* We do this, since in optimal case we just do ++max. */
$max = --$iss;
}
q('INSERT INTO {SQL_TABLE_PREFIX}tv_'. $forum_id .' (thread_id,iss,seq) VALUES('. $th .','. (int)$sticky .','. (++$max) .')');

if (isset($ll)) {
db_unlock();
}
}

function th_reply_rebuild($forum_id, $th, $sticky)
{
if (!db_locked()) {
$ll = 1;
db_lock('{SQL_TABLE_PREFIX}tv_'. $forum_id .' WRITE');
}

/* Get first topic of forum (highest seq). */
list($max,$tid,$iss) = db_saq(q_limit('SELECT /* USE MASTER */ seq,thread_id,iss FROM {SQL_TABLE_PREFIX}tv_'. $forum_id .' ORDER BY seq ASC', 1));

if ($tid == $th) {
/* NOOP: quick elimination, topic is already 1st. */
} else if (!$iss || ($sticky && $iss < Cool) { /* Moving to the very top. */
/* Get position. */
$pos = q_singleval('SELECT /* USE MASTER */ seq FROM {SQL_TABLE_PREFIX}tv_'. $forum_id .' WHERE thread_id='. $th);
/* Move everyone ahead, 1 down. */
q('UPDATE {SQL_TABLE_PREFIX}tv_'. $forum_id .' SET seq=seq-1 WHERE seq>'. $pos);
/* Move to top of the stack. */
q('UPDATE {SQL_TABLE_PREFIX}tv_'. $forum_id .' SET seq='. $max .' WHERE thread_id='. $th);
} else {
/* Get position. */
$pos = q_singleval('SELECT /* USE MASTER */ seq FROM {SQL_TABLE_PREFIX}tv_'. $forum_id .' WHERE thread_id='. $th);
/* Find oldest sticky message. */
$iss = q_singleval(q_limit('SELECT /* USE MASTER */ seq FROM {SQL_TABLE_PREFIX}tv_'. $forum_id .' WHERE seq>'. ($max - 50) .' AND iss>'. ($sticky && $iss >= 8 ? '=8' : '0') .' ORDER BY seq ASC', 1));
/* Move everyone ahead, unless sticky, 1 down. */
q('UPDATE {SQL_TABLE_PREFIX}tv_'. $forum_id .' SET seq=seq-1 WHERE seq BETWEEN '. ($pos + 1) .' AND '. ($iss - 1));
/* Move to top of the stack. */
q('UPDATE {SQL_TABLE_PREFIX}tv_'. $forum_id .' SET seq='. ($iss - 1) .' WHERE thread_id='. $th);
}

if (isset($ll)) {
db_unlock();
}
}

[Updated on: Sat, 31 March 2012 21:33]

Report message to a moderator

[Message index]
 
Read Message
Previous Topic: NNTP Import Problems
Next Topic: Importing old forum files broke my new forum.
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 16:46:45 GMT 2024

Total time taken to generate the page: 0.04171 seconds