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

Home » FUDforum Development » Plugins and Code Hacks » [MOD] 10 Recent Topics  () 3 Votes
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
icon10.gif  [MOD] 10 Recent Topics [message #166161] Tue, 04 October 2011 19:52 Go to previous message
SecTest is currently offline  SecTest   Germany
Messages: 7
Registered: August 2011
Karma:
Junior Member
Hi,

I created this mod for my site, and i want to share it with you. I think many peoples need it Wink

1) recenttopics.inc.t
(Create "recenttopics.inc.t" in "../src/" folder)
<?
/*
Mod Recent Topics
Author: LHT
*/
function enable_recenttopics()
{
	// Queries
	$get_thread_informations = q('SELECT id,last_post_date,replies,views,last_post_id FROM '. $GLOBALS['DBHOST_TBL_PREFIX'] .'thread ORDER BY last_post_date DESC LIMIT 20');
	$RECENT_TOPICS = array (
		0  	=> array(),
		1   => array(),
		2   => array(),
		3   => array(),
		4   => array(),
		5   => array(),
		6   => array(),
		7   => array(),
		8   => array(),
		9   => array()
	);
	$RECENT_TOPICS_COUNT = 0;
	while($store_array = db_rowarr($get_thread_informations)) {
		$RECENT_TOPICS[$RECENT_TOPICS_COUNT]['THREADID']=$store_array[0];
		$RECENT_TOPICS[$RECENT_TOPICS_COUNT]['DATE']=date("D, d F Y",$store_array[1]);
		$RECENT_TOPICS[$RECENT_TOPICS_COUNT]['REPLIES']=$store_array[2];
		$RECENT_TOPICS[$RECENT_TOPICS_COUNT]['VIEWS']=$store_array[3];
		$RECENT_TOPICS[$RECENT_TOPICS_COUNT]['LASTPOSTID']=$store_array[4];
		$RECENT_TOPICS[$RECENT_TOPICS_COUNT]['SUBJECT']= q_singleval('SELECT subject FROM '. $GLOBALS['DBHOST_TBL_PREFIX'] .'msg WHERE thread_id='. $store_array[0]);
		if(sizeof($RECENT_TOPICS[$RECENT_TOPICS_COUNT]['SUBJECT'])>0)
		{
			$RECENT_TOPICS[$RECENT_TOPICS_COUNT]['POSTERID']= q_singleval('SELECT poster_id FROM '. $GLOBALS['DBHOST_TBL_PREFIX'] .'msg WHERE thread_id='. $store_array[0]);
			$RECENT_TOPICS[$RECENT_TOPICS_COUNT]['POSTERALIAS']=q_singleval('SELECT alias FROM '. $GLOBALS['DBHOST_TBL_PREFIX'] .'users WHERE id='.$RECENT_TOPICS[$RECENT_TOPICS_COUNT]['POSTERID']);
			$RECENT_TOPICS[$RECENT_TOPICS_COUNT]['LASTPOSTERID']= q_singleval('SELECT poster_id FROM '. $GLOBALS['DBHOST_TBL_PREFIX'] .'msg WHERE id='. $store_array[4]);
			$RECENT_TOPICS[$RECENT_TOPICS_COUNT]['LASTPOSTERALIAS']=q_singleval('SELECT alias FROM '. $GLOBALS['DBHOST_TBL_PREFIX'] .'users WHERE id='.$RECENT_TOPICS[$RECENT_TOPICS_COUNT]['LASTPOSTERID']);
			$RECENT_TOPICS_COUNT++;
		}else
		{
			$RECENT_TOPICS_COUNT--;
		}
	}
	// Recent Topics Table's body
	for($RECENT_TOPICS_COUNT=0;$RECENT_TOPICS_COUNT<10;$RECENT_TOPICS_COUNT++)
	{
		echo '
<tr class="row">
	<td class="RowStyleB nw">'. $RECENT_TOPICS_COUNT .'</td>
	<td colspan="3" class="RowStyleA wa"><a href="index.php?t=msg&amp;th='. $RECENT_TOPICS[$RECENT_TOPICS_COUNT]['THREADID'] .'&amp;start=0&amp;">'. $RECENT_TOPICS[$RECENT_TOPICS_COUNT]['SUBJECT'] .'</a></td>
	<td class="RowStyleA nw"><a href="index.php?t=usrinfo&id='. $RECENT_TOPICS[$RECENT_TOPICS_COUNT]['POSTERID'] .'&">'. $RECENT_TOPICS[$RECENT_TOPICS_COUNT]['POSTERALIAS'] .'</a></td>
	<td class="RowStyleB nw">'. $RECENT_TOPICS[$RECENT_TOPICS_COUNT]['REPLIES'] .'</td>
	<td class="RowStyleB nw">'. $RECENT_TOPICS[$RECENT_TOPICS_COUNT]['VIEWS'] .'</td>
	<td class="RowStyleA nw"><a href="index.php?t=usrinfo&id='. $RECENT_TOPICS[$RECENT_TOPICS_COUNT]['LASTPOSTERID'] .'&">'. $RECENT_TOPICS[$RECENT_TOPICS_COUNT]['LASTPOSTERALIAS'] .'</a></td>
	<td class="RowStyleB nw">'. $RECENT_TOPICS[$RECENT_TOPICS_COUNT]['DATE'] .'</td>
	
</tr>';
	}
	// Recent Topics Table's foot
	echo '
	</table><br>';
	// Free Memory
	unset($get_thread_informations);
	unset($store_array);
	unset($RECENT_TOPICS);
}
?>


2) recenttopics.tmpl
(Create recenttopics.tmpl in ../thm/YOUR_THEME_NAME/tmpl/ folder)
{PHP_FILE: input: recenttopics.inc.t; output: recenttopics.inc;}
{MAIN_SECTION: recenttopics RecentTopics}
<table cellspacing="1" cellpadding="2" class="ContentTable">
<tr>
	<th class="nw">{MSG: rated}</th>
	<th colspan="3" class="wa">10 {MSG: usrinfo_last_post}</th>
	<th class="nw">{MSG: starter}</th>
	<th class="nw">{MSG: replies}</th>
	<th class="nw">{MSG: views}</th>
	<th class="nw">{MSG: last_poster}</th>
	<th class="nw">{MSG: date_posted}</th>
</tr>
	{FUNC: enable_recenttopics()}
{MAIN_SECTION: END}


3) Modify index.tmpl
(Open "index.tmpl" in "../thm/YOUR_THEME_NAME/tmpl/" with Text Editor)
=============================================================
Find:
{REF: draw_forum_list.tmpl}

Add after:
{REF: recenttopics.tmpl}

=============================================================
Find:
{TEMPLATE-DATA: announcements}

Add after:
{TEMPLATE: recenttopics}


4) Modify language file
(Open "msg" in ../thm/YOUR_THEME_NAME/i18n/YOUR_LANG/ with Text Editor)
Add:
rated:Rated
starter:Starter
last_poster: Last Poster


5) Rebuild your Template from Admin Panel !



[Message index]
 
Read Message icon10.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Using mailman, fud, /etc/aliases, maillist.php, and custom filter scripts
Next Topic: Spotify plugin
Goto Forum:
  

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

Current Time: Sat Dec 21 14:30:49 GMT 2024

Total time taken to generate the page: 0.04523 seconds