SEO-Board: Free, Fast and Search Engine Optimization Friendly Forum Script
»User: »Password:   Remember Me? 
SEO-Board Forum Software Community / General / Support / Sticky posts staying on top of Latest Posts
Posted:  17 May 2005 18:06
is it possible to get my sticky posts to show as always the first posts when Latest Posts are displayed? Right now, the sticky just gets pushed down as people post afterwards and Latest Posts is going by time posted instead of Sticky status. Thanks to anyone who has suggestions.
Posted:  17 May 2005 19:21
You can do it very easily. In board.php replace this code:
Code:

  if (count($userprivateforums)==0)
    $result = mysql_query("SELECT topic_id, topic_title, topic_poster_name, topic_poster_id, topic_lastposter_name, topic_lastposter_id, topic_created_time, topic_lastpost_time, topic_numreplies, topic_numviews, topic_sticky, topic_locked, topic_moved FROM {$dbpref}topics ORDER BY topic_lastpost_time DESC LIMIT $shownumlastposts");
  else
  {
    $where = 'WHERE forum_id<>'.implode(' AND forum_id<>', $userprivateforums);
    $result = mysql_query("SELECT topic_id, topic_title, topic_poster_name, topic_poster_id, topic_lastposter_name, topic_lastposter_id, topic_created_time, topic_lastpost_time, topic_numreplies, topic_numviews, topic_sticky, topic_locked, topic_moved FROM {$dbpref}topics $where ORDER BY topic_lastpost_time DESC LIMIT $shownumlastposts");
  }
by this code
Code:

  if (count($userprivateforums)==0)
    $result = mysql_query("SELECT topic_id, topic_title, topic_poster_name, topic_poster_id, topic_lastposter_name, topic_lastposter_id, topic_created_time, topic_lastpost_time, topic_numreplies, topic_numviews, topic_sticky, topic_locked, topic_moved FROM {$dbpref}topics ORDER BY topic_sticky DESC, topic_lastpost_time DESC LIMIT $shownumlastposts");
  else
  {
    $where = 'WHERE forum_id<>'.implode(' AND forum_id<>', $userprivateforums);
    $result = mysql_query("SELECT topic_id, topic_title, topic_poster_name, topic_poster_id, topic_lastposter_name, topic_lastposter_id, topic_created_time, topic_lastpost_time, topic_numreplies, topic_numviews, topic_sticky, topic_locked, topic_moved FROM {$dbpref}topics $where ORDER BY topic_sticky DESC, topic_lastpost_time DESC LIMIT $shownumlastposts");
  }


Basically you add "topic_sticky DESC" to the order by statement.

That will show sticky topics on the top. If you want to include the sticky, moved etc. prefixes you need to add this code:
Code:

      $topic_ind = array ();
      if ($sticky == 1)
        array_push($topic_ind, $lang['sticky']);
      if ($moved == 1)
        array_push($topic_ind, $lang['moved']);
      if ($locked == 1)
        array_push($topic_ind, $lang['locked']);
      if (!empty($topic_ind))
        $topic_link .= ' <sup>'.implode(', ',$topic_ind).'</sup>';


Just compare the code of board.php and vforum.php to see all the difference.
Posted:  17 May 2005 21:03
Shouldn't this be in there anyway since thats the point of sticky topics?
Posted:  17 May 2005 21:16
I was thinking the same thing cleric
Posted:  17 May 2005 22:37
The point of latest posts is to display latest posts. If you have a couple of stickies like forum rules, read faq before asking for support etc., they will end up occupying all the top spots in latests posts. Latests posts is for visitors who stop by to check for new posts etc. They have already read all the stickies. And if the stickies are new, they will be shown in latest posts. This is the way all forums are built.
Posted:  17 May 2005 23:01
/sign Hristo.
Posted:  17 May 2005 23:19
now that you say that hristo, I didn't relize that he was talking about the latest posts on the main index page, i thought it was on teh forums page
Posted:  18 May 2005 12:51
Yeah i got the same idea sujokid...woops
Posted:  19 May 2005 04:33
Great, works perfectly and thanks a lot!!