Add New Posts Link to SEO Board Forums
Views Today: 7, Total Views: 5761, Submitted by: Python on 29-06-2006
This tutorial is written for those of you running SEO-Board.
It will take you through the steps to adding a link on your forum which when clicked will display the new posts since you last logged in.
Firstly create a new file and call it newposts.php
Then copy and paste the following into it:
Code
<?php
if(!defined(\'SEO-BOARD\'))
{
die($lang[\'fatal_error\']);
}
$title = $forumtitle;
require(\'forumheader.php\');
if ($user_id == 0)
{
print eval(get_template(\'newpostsguest\'));
} else {
$cell_iterator = 0;
//exclude private to the current user forums + the ones in $lastpostsexclude
$userprivateforums = get_invisible_forums($user_id);
if (!empty($lastpostsexclude))
$userprivateforums = array_unique(array_merge($userprivateforums, $lastpostsexclude));
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 WHERE topic_lastpost_time > $user_lastsession ORDER BY topic_lastpost_time DESC\");
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 AND topic_lastpost_time > $user_lastsession ORDER BY topic_lastpost_time DESC\");
}
if (mysql_num_rows($result) != 0)
{
$topics_html = array();
$template_topic = get_template(\'mainlastpostscell\');
while($row = mysql_fetch_row($result))
{
list($id, $title, $author, $author_id, $lastposter, $lastposter_id, $createdtime, $lastposttime, $num_replies, $num_views, $sticky, $locked, $moved) = $row;
$topic_link = get_topic_link($id, $title, $num_replies+1, \'topiclink\');
if (($lastposttime > $user_lastsession) && ($lastposter_id != $user_id) && ($user_id != 0))
if ($createdtime < $user_lastsession) //created before lastsession
$topic_link = \'<sup>\'.$lang[\'new\'].\'</sup> \'.$topic_link;
else//created after lastsession
if ($author_id != $user_id)
$topic_link = \'<sup>\'.$lang[\'new\'].\'</sup> \'.$topic_link;
$started_by = $lang[\'started_by\'].\' \'.$author;
$lastpost = $lastposter.\'<br>\'.format_datetime($lastposttime, $user_timezone);
array_push($topics_html, eval($template_topic));
$cell_iterator = 1 - $cell_iterator;
}
$topics_html = implode(\'\', $topics_html);
print eval(get_template(\'mainlastposts\'));
unset($template_topic);
} else {
print eval(get_template(\'nonewposts\'));
}
}
?>
Upload that file into your forum directory.
Create a file called newpostguest.htm
Copy and paste the following into that file
Code
<center><div class=message>View New Posts<br><br>You must be logged in to search for new posts!</div></center>
Create a file called nonewposts.htm
Copy and paste the following into that file
Code
<center><div class=message>No New Posts<br><br>There have been no new posts since you last visited!</div></center>
Upload both of those files into your skin directory.
Now open up your index.php file. Find the following:
Code
!in_array($a, array (\'login\',\'logout\',\'register\',\'vforum\',\'vtopic\',\'forgotpass\',\'usercp\',
\'editpost\',\'delpost\',\'toggletopic\',\'movetopic\',\'deltopic\',\'edittopic\',
\'forumjump\',\'member\',\'search\', \'viewip\')))
Replace it with the following:
Code
!in_array($a, array (\'login\',\'logout\',\'register\',\'vforum\',\'vtopic\',\'forgotpass\',\'usercp\',
\'editpost\',\'delpost\',\'toggletopic\',\'movetopic\',\'deltopic\',\'edittopic\',
\'forumjump\',\'member\',\'search\', \'viewip\', \'newposts\')))
Then simply edit the mainmembernavigation.htm file in your skin directory and add a link like this:
http://www.tutorialdash.com/forum/index.php?a=newposts
You can see this in action at our discussion forum.
Post A Comment
If you want to comment on this tutorial you must first register or login.



Syndicate