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
Switch to threaded view of this topic Create a new topic Submit Reply
icon10.gif  [MOD] 10 Recent Topics [message #166161] Tue, 04 October 2011 19:52 Go to next message
SecTest is currently offline  SecTest   Germany
Messages: 7
Registered: August 2011
Karma: 2
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 !



Re: [MOD] 10 Recent Topics [message #166184 is a reply to message #166161] Sun, 09 October 2011 12:39 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3772
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Excellent mod, thanks!

On a side note: mods like these are kind of difficult to install. If you have time, it would be great if you can refactor it into a plugin.
Re: [MOD] 10 Recent Topics [message #166206 is a reply to message #166161] Tue, 11 October 2011 06:21 Go to previous messageGo to next message
The Witcher is currently offline  The Witcher   United States
Messages: 675
Registered: May 2009
Location: USA
Karma: 3
Senior Member
I like it!
Works great with the Default, Twilight grey, and Forest green themes! But not so much with the path or L/R aligned themes so far.

The path info theme "index.tmpl" doesn't have a "{TEMPLATE-DATA: announcements}" line of code so the installation for path_info themes ended halfway through step #3.

Currently attempting to use path theme returns:

Please fix theme forestgreen_path: Undefined template: "TEMPLATE" inside "recenttopics".
or
Please fix theme forestgreen_path: Undefined template: "TEMPLATE" inside "registered_on_date".

Any ideas on how to fix that?


"I'm a Witcher, I solve human problems; not always using a sword!"
Re: [MOD] 10 Recent Topics [message #166209 is a reply to message #166206] Tue, 11 October 2011 13:19 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3772
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
The path_info theme should probably not have a index.tmpl" at all. Please rename/delete it and let us know if it helps.
Re: [MOD] 10 Recent Topics [message #166213 is a reply to message #166209] Tue, 11 October 2011 16:21 Go to previous messageGo to next message
The Witcher is currently offline  The Witcher   United States
Messages: 675
Registered: May 2009
Location: USA
Karma: 3
Senior Member
Quote:
probably not have a index.tmpl" at all.
???? I guess I don't understand, index.tmpl already exists in path_info, but it was not included in the Path template set I used
This is from an as yet unused original install of 3.0.3 /thm/path_info/tmpl/index.tmpl
/**
* copyright            : (C) 2001-2011 Advanced Internet Designs Inc.
* email                : forum(at)prohost(dot)org
* $Id: index.tmpl 5264 2011-05-16 16:29:13Z naudefj $
*
* This program is free software; you can redistribute it and/or modify it 
* under the terms of the GNU General Public License as published by the 
* Free Software Foundation; version 2 of the License. 
**/

{PHP_FILE: input: index.php.t; output: index.php;}
{REF: security.tmpl}
{REF: logedin.tmpl}
{REF: admincp.tmpl}
{REF: header.tmpl}
{REF: footer.tmpl}
{REF: curtime.tmpl}
{REF: usercp.tmpl}
{REF: stats.tmpl}
{REF: show.tmpl}
{REF: quicklogin.tmpl}
{REF: draw_forum_list.tmpl}

{SECTION: mark_all_read_lnk}
{ROOT}/mar/0/{VAR: cat_id}/{DEF: _rsid}?SQ={GVAR: sq}
{SECTION: END}

My test was done using the default, twilight, and forest green themes, and it was only when attempting to use a path info based theme that it failed. I presumed at least in part because of the absence of a place in path_info/tmpl/index.tmpl to insert the second half of step #3 into!
Find:
{TEMPLATE-DATA: announcements}
Add after:
{TEMPLATE: recenttopics}

My second thought was that the mods layout might not be compatible with the left aligned themes!
I've already restored the forum Data dump and deleted all custom themes, so I can redo the process from scratch and see what else we can find out.



"I'm a Witcher, I solve human problems; not always using a sword!"
Re: [MOD] 10 Recent Topics [message #166214 is a reply to message #166213] Tue, 11 October 2011 23:42 Go to previous messageGo to next message
SecTest is currently offline  SecTest   Germany
Messages: 7
Registered: August 2011
Karma: 2
Junior Member
I remember that Path_Info uses Data from other Theme. Did you try to build Default theme first, then build Path_Info ?

@naudefi: Thanks, I'll try to make it into plugin later when i have time.
Re: [MOD] 10 Recent Topics [message #166215 is a reply to message #166214] Wed, 12 October 2011 09:48 Go to previous messageGo to next message
The Witcher is currently offline  The Witcher   United States
Messages: 675
Registered: May 2009
Location: USA
Karma: 3
Senior Member
SecTest wrote on Tue, 11 October 2011 18:42
I remember that Path_Info uses Data from other Theme. Did you try to build Default theme first, then build Path_Info ?

@naudefi: Thanks, I'll try to make it into plugin later when i have time.

Correct, and Yes I did, but I think I've got it now, thanks! It looks like a large part of the problem was my trying to build and implement it into a custom path theme at the same time I installed it rather than Just applying it directly to path_info itself and then building a new template set.

It seems the Mod doesn't need to be applied to every template set individually; applying it to the default and path info template sets works so far for all the included stock FUDforum template sets/themes (although it appears you can add it individually if you don't want it on every theme).

Only the 1st half of step 3 can or apparently needs to be applied to path_info's index.tmpl (like you said "Path_Info uses Data from other Themes/template sets" and I guess that's part of it).

I still want to fiddle with it some, and there are a few things I'd like to change for my own preferences (Last 10 Messages instead of 10 Last Message, Started By instead of starter, ability to change the number of msg's to show + or -).

All in all I like it a lot more than I thought I would, and I'm seeing more potential than at 1st glance.




"I'm a Witcher, I solve human problems; not always using a sword!"
Re : Re: [MOD] 10 Recent Topics [message #168089 is a reply to message #166215] Thu, 24 January 2013 21:11 Go to previous message
TheDude is currently offline  TheDude
Messages: 120
Registered: November 2012
Location: France
Karma: 2
Senior Member
Awesome mod : works perfectly !
Thanks
TheDude


  Switch to threaded view of this topic Create a new topic Submit Reply
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:26:08 GMT 2024

Total time taken to generate the page: 0.02194 seconds