{REQUEST} - Topics Anywhere for phpBB 3.x.

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Suggested Hosts
Locked
midwestbonsai
Registered User
Posts: 177
Joined: Sat May 28, 2005 12:48 am
Location: Wisconsin USA
Contact:

[REQUEST] Recent Posts on Home Page

Post by midwestbonsai » Sat May 26, 2007 1:41 pm

I would need a MOD that will allow me to list the 5 or so most recent posts to the forum on my home page (outside of the forum). I am doing this now with phpbb2 with no troubles and would need this ability before I could switch to the new forum software.
Thanks

starry-eyed
Registered User
Posts: 9
Joined: Sun May 27, 2007 3:55 am

Re: [REQUEST] Recent Posts on Home Page

Post by starry-eyed » Wed May 30, 2007 12:36 am

bump ... I need this mod as well.

starry-eyed
Registered User
Posts: 9
Joined: Sun May 27, 2007 3:55 am

Re: [REQUEST] Recent Posts on Home Page

Post by starry-eyed » Wed May 30, 2007 5:42 pm

Here is a script on recent posts/topics that is working great on phpBB2 but its SQL command no longer works on phpBB3. Anyone out there check the SQL command and make it work on phpBB3?

Code: Select all

<? 
/**
* Mod Title:   Latest posts/topics
* Mod Version: phpBB 2.0
* Author:      Pegas (pegas@ami.cz) (originally made by ?, previous version by LiLCoolboy (M@urice Cheung))
* Description: Shows latest posts or topics on any page, 2 optional parameters
* Release:     v3.0, 27.01.2003
***
* DeMo:                http://kocky-online.cz (Czech language) 
* Installation Level:  Easy 
* Installation Time:   5 minutes 
* Files To Edit:       0 
* Included Files:      (if necessary) 
***
* Installation Notes:
* Put this code into new file, set $serverPath and $urlPath, 
* upload this file onto server and include into your page and you are done!
*   -- OR --
* Put this code into your page, set $serverPath and $urlPath, 
* and you are done!
***
* Parameters:
* There are 2 optional parameters when calling this code as standalone file via include!
* type - whether to show topics or posts
*   type=posts  - posts [default when missing]
*   type=topics - topics
* count - how much posts/topics show
*   count=# [default is 3]
***
* Examples (assume that your file with this code is hilites.php):
* hilites.php?type=topics&count=5
*  - shows latest 5 topics
* hilites.php?type=topics
*  - shows latest 3 topics
* hilites.php
*  - shows latest 3 posts
***
* Revision:
* v1.0 
*  author: ?
* v2.0
*  author: LiLCoolboy (M@urice Cheung) 
*  - not working without significant changes, mistypes
* v3.0
*  author: Petr Gasparik
*  + added parameters when called as standalone file
*  + posts/topics selection corrected
*  + corrected mistypes
*/
$urlPath = "ABSOLUTE_PATH_OF_YOUR_FORUM";	//example: if your forum URL looks like http://kocky-online.cz/forum, this should be "/forum"
$serverPath = "PATH_TO/config.php";			//example: when this file is in URL path /forum/mod, this should be ../config.php
if(empty($count))
	$count = "3";									//default value of how many posts/topics to show
if(empty($type))
	$type = "posts";		//default value of whether to show 'posts' or 'topics' 
$titleLimit = 30;			//this is max.length of 'title' of topic/post
$moreLimit = 20;			//this is max.length of 'more' (used in posts)

//-----------------[ DO NOT EDIT BELOW HERE ]------------------------- 
include_once("$serverPath"); 
$db = @mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("here we die at connection"); 
@mysql_select_db("$dbname",$db) or die("here we die"); 

if($type == "posts") 
{
	$prefix = 'p';
   $sql = "SELECT x.post_subject as title, p.post_id as id, f.forum_id, t.topic_title as more "
   		."FROM ${table_prefix}topics t, ${table_prefix}forums f, ${table_prefix}posts p, ${table_prefix}posts_text x "
   		."WHERE t.topic_id = p.topic_id AND f.forum_id = t.forum_id AND p.post_id = x.post_id "
   		."ORDER BY p.post_id DESC "
   		."LIMIT $count"; 
}
else 
{
	$prefix = 't';
   $sql = "SELECT t.topic_title as title, t.topic_id as id, f.forum_id, '' as more "
   		."FROM ${table_prefix}topics t, ${table_prefix}forums f "
   		."WHERE f.forum_id = t.forum_id "
   		."ORDER BY topic_time DESC "
   		."LIMIT $count"; 
}

//echo $sql;

if($r = mysql_query($sql, $db)) { 
	while($m = mysql_fetch_array($r)) { 
		$j = stripslashes($m[title]); 
		$k = substr($j, 0, $titleLimit) . "..."; 
		if(!empty($m[more]))
			$m[more] = '('.substr($m[more], 0, $moreLimit) . '...)'; 
		if ($type == 'posts') {
			$anchor = '#'.$m[id];
		}
		//-------------------[ THIS IS ONLY LINE YOU COULD CHANGE ]--------------------------
		echo "<a title=\"$m[title]\" href=\"$urlPath/viewtopic.php?${prefix}=$m[id]&sid=$m[forum_id]${anchor}\">$k</a> $m[more]<br>"; 
	} 
} 
/
//-------------------[ DO NOT EDIT UP HERE ]--------------------------
?>

midwestbonsai
Registered User
Posts: 177
Joined: Sat May 28, 2005 12:48 am
Location: Wisconsin USA
Contact:

Re: [REQUEST] Recent Posts on Home Page

Post by midwestbonsai » Fri Jun 01, 2007 11:39 pm

starry-eyed wrote:Here is a script on recent posts/topics that is working great on phpBB2 but its SQL command no longer works on phpBB3. Anyone out there check the SQL command and make it work on phpBB3?
that would be sweet!

User avatar
Volunteer Forum
Registered User
Posts: 400
Joined: Mon Sep 12, 2005 9:59 pm

Re: [REQUEST] Recent Posts on Home Page

Post by Volunteer Forum » Sat Jun 02, 2007 4:33 pm

I have talked to the author of "Topic Extraction" for phpBB2
So he is now corrently working on one for phpBB3
Everything that is not perfect is a flaw [",]

midwestbonsai
Registered User
Posts: 177
Joined: Sat May 28, 2005 12:48 am
Location: Wisconsin USA
Contact:

Re: [REQUEST] Recent Posts on Home Page

Post by midwestbonsai » Sat Jun 02, 2007 8:37 pm

Volunteer Forum wrote:I have talked to the author of "Topic Extraction" for phpBB2
So he is now corrently working on one for phpBB3
This is wonderful news!

dudeness3
Registered User
Posts: 2
Joined: Tue Dec 12, 2006 10:56 pm

Re: [REQUEST] Recent Posts on Home Page

Post by dudeness3 » Sun Jun 03, 2007 4:32 am

I hope he finishes soon, I really, really want this.

starry-eyed
Registered User
Posts: 9
Joined: Sun May 27, 2007 3:55 am

Re: [REQUEST] Recent Posts on Home Page

Post by starry-eyed » Sun Jun 03, 2007 7:08 am

The script I've posted above actually works for phpBB3. Initially I thought it didn't work but I later found out that the problem was not on the script but on my server.

You may just add the following on the SQL WHERE clause:

p.post_approved = 1
t.topic_approved = 1

so that unapproved posts and topics will not show up.

midwestbonsai
Registered User
Posts: 177
Joined: Sat May 28, 2005 12:48 am
Location: Wisconsin USA
Contact:

Re: [REQUEST] Recent Posts on Home Page

Post by midwestbonsai » Sun Jun 03, 2007 2:15 pm

Hmmm didn't work for me.

User avatar
johnnyvang
Registered User
Posts: 10
Joined: Thu May 31, 2007 9:19 pm

Re: [REQUEST] Recent Posts on Home Page

Post by johnnyvang » Mon Jun 04, 2007 7:32 am

This is easy to do :D and no MOD needed.

(your forum is on http://www.yoursite.com/forum , if you have another folder rename forum/ into the one you have.)

First create a page called lasttopic.php
Insert:

Code: Select all

<? include_once ("forum/config.php");
   $mysql_connection = mysql_connect ($dbhost, $dbuser, $dbpasswd) or die ("Connection failed");
   mysql_select_db ($dbname) or die ("Selecting database failed");

   $query = "SELECT topic_id,topic_title FROM phpbb3_topics order by topic_id desc limit 10
   ";
   $res   = mysql_query($query);
   while($data = @mysql_fetch_array($res))
   {
    echo "&nbsp;<a href=\"forum/viewtopic.php?t=".$data["topic_id"]."\">".$data['topic_title']."</a><br>";
   }
?>

On the index or where you want to last topics show, you enter this little code:

Code: Select all

<iframe src ="lasttopic.php" width="80%" height="130%" frameborder="0" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
The frame code 80x130 is just high/widht enough to so all subjects.
Upload the file lasttopic.php in public_html if your index is there.


The line:

Code: Select all

$query = "SELECT topic_id,topic_title FROM phpbb3_topics order by topic_id desc limit 10
let's you show the last 10 topics.
Rename 10 into 5 to show the last 5 topics.

User avatar
Scorpio
Registered User
Posts: 32
Joined: Tue Jul 31, 2001 8:29 am
Location: Tampere, Finland, Europe
Contact:

Re: [REQUEST] Recent Posts on Home Page

Post by Scorpio » Mon Jun 04, 2007 3:26 pm

Thanks Johnny :D

That's allmost what I've been looking...

Can you say how could one add small part of the posts text bellow that. :oops:


And is it possible to get the same formating (Bold/itallis/...) as in phpBB or is that an overkill... :shock:

User avatar
johnnyvang
Registered User
Posts: 10
Joined: Thu May 31, 2007 9:19 pm

Re: [REQUEST] Recent Posts on Home Page

Post by johnnyvang » Mon Jun 04, 2007 4:49 pm

Can you say how could one add small part of the posts text bellow that.
Don't know how to do that.
I only show the topic subject and it works for me.
And is it possible to get the same formating (Bold/itallis/...) as in phpBB or is that an overkill...
This code (in the IFRAME) takes the same format as in your css file (like the other text on your mainpage.)
Maybe it's possible to add <font size=""></font> before it but i don't know if that will work..

User avatar
IoanFilipov
Translator
Posts: 33
Joined: Wed May 02, 2007 7:40 pm

Re: [REQUEST] Recent Posts on Home Page

Post by IoanFilipov » Mon Jun 04, 2007 6:43 pm

Here is the upgraded version

Code: Select all

<?php

//Path to the forum config.php file
include "config.php";

//Forum address, without dash at the end

$forum_address = "http://myforum.com/forum";

//Number of the latest topics

$latest = 10;

$link = $link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd");

if (!$link)

{

	die('Not connected : ' . mysql_error());

}

$db_selected = mysql_select_db("$dbname", $link);

if (!$db_selected)

{

	die ('Can\'t use foo : ' . mysql_error());

}

mysql_query("SET NAMES UTF8");

$get_url = "SELECT config_name, config_value FROM $table_prefix".config." WHERE config_name = 'server_name' LIMIT 0,1";

$url = mysql_query($get_url);

$url = mysql_fetch_array($url);
$latest_topics;
//to add excluded forum add "AND forum_id<>$id_to_the_forum" after "topic_approved = '1'"
$latest_topics = "SELECT * FROM $table_prefix".topics." WHERE topic_approved = '1' AND forum_id<>17 ORDER BY topic_last_post_time DESC LIMIT 0,$latest";

$topics = mysql_query($latest_topics);

while($row = mysql_fetch_array($topics))
{
	extract($row);
	$date = date("d.m.Y", $topic_last_post_time);
?>
	<a href="http://<?php $forum_address; ?>/viewtopic.php?f=<?= $forum_id ?>&t=<?= $topic_id ?>" title="<?= $topic_title ?>"><?= $topic_title ?></a> / <?= $date ?> / replies (<?= $topic_replies ?>)<br>
<?php
}
?>
Last edited by IoanFilipov on Mon Mar 24, 2008 6:40 pm, edited 1 time in total.

User avatar
Volunteer Forum
Registered User
Posts: 400
Joined: Mon Sep 12, 2005 9:59 pm

Re: [REQUEST] Recent Posts on Home Page

Post by Volunteer Forum » Tue Jun 05, 2007 10:06 am

johnnyvang wrote:This is easy to do :D and no MOD needed.

(your forum is on http://www.yoursite.com/forum , if you have another folder rename forum/ into the one you have.)

First create a page called lasttopic.php
Insert:

Code: Select all

<? include_once ("forum/config.php");
   $mysql_connection = mysql_connect ($dbhost, $dbuser, $dbpasswd) or die ("Connection failed");
   mysql_select_db ($dbname) or die ("Selecting database failed");

   $query = "SELECT topic_id,topic_title FROM phpbb3_topics order by topic_id desc limit 10
   ";
   $res   = mysql_query($query);
   while($data = @mysql_fetch_array($res))
   {
    echo "&nbsp;<a href=\"forum/viewtopic.php?t=".$data["topic_id"]."\">".$data['topic_title']."</a><br>";
   }
?>

On the index or where you want to last topics show, you enter this little code:

Code: Select all

<iframe src ="lasttopic.php" width="80%" height="130%" frameborder="0" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
The frame code 80x130 is just high/widht enough to so all subjects.
Upload the file lasttopic.php in public_html if your index is there.


The line:

Code: Select all

$query = "SELECT topic_id,topic_title FROM phpbb3_topics order by topic_id desc limit 10
let's you show the last 10 topics.
Rename 10 into 5 to show the last 5 topics.
[/size]

Well, this worked. But i also want some of the text with it..
Everything that is not perfect is a flaw [",]

midwestbonsai
Registered User
Posts: 177
Joined: Sat May 28, 2005 12:48 am
Location: Wisconsin USA
Contact:

Re: [REQUEST] Recent Posts on Home Page

Post by midwestbonsai » Tue Jun 05, 2007 11:44 am

@johnnyvang

This did work, but is there anyway to make it xhtml 1.0 strict valid?


@IoanFilipov

This did not work for me at all, nothing but errors.

Thanks

Locked

Return to “[3.0.x] MOD Requests”