Top

Latest post on your homepage ( phpbb )


PHP Code

Please Register to submit score.
Bookmark and Share
Average Score  7.7 (of 3 scores)
Date Added  Nov 14, 2008
Last Updated  Nov 15, 2008

Description

This is a php code it show the latest forum post with phpBB3 on the homepage of your website. It work with your config.php in your PHPBB directory. If you wish to show more then the latest 5 posts you can change the $topicnumber to whatever you wish to display.

Grab the Code

<?php
    // How Many Topics you want to display?
    $topicnumber = 5;
    // Change this to your phpBB path
    $urlPath = "/phpbb";
 
    // Database Configuration (Where your phpBB config.php file is located)
    include 'phpbb/config.php';
 
    $table_topics = $table_prefix. "topics";
    $table_forums = $table_prefix. "forums";
    $table_posts = $table_prefix. "posts";
    $table_users = $table_prefix. "users";
    $link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Could not connect");
    mysql_select_db("$dbname") or die("Could not select database");
 
    $query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
    FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
    WHERE t.topic_id = p.topic_id AND
    f.forum_id = t.forum_id AND
    t.forum_id != 4 AND
    t.topic_status <> 2 AND
    p.post_id = t.topic_last_post_id AND
    p.poster_id = u.user_id
    ORDER BY p.post_id DESC LIMIT $topicnumber";
    $result = mysql_query($query) or die("Query failed");									
 
    print "<table cellpadding='3' cellSpacing='2' width='640'>";
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
 
    echo  "<tr valign='top'><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#FFCC00\"><b><a href=\"$urlPath/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]&p=$row[post_id]#p$row[post_id]\" TARGET=\"_blank\">" .
    $row["topic_title"] .
    "</a></td></font></b><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#C0C0C0\"> by: <a href=\"$urlPath/memberlist.php?mode=viewprofile&u=$row[user_id]\" TARGET=\"_blank\">" .
    $row["username"] .
    "</td><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#C0C0C0\">" .
    date('F j, Y, g:i a', $row["post_time"]) .
    "</td></tr></font>";
    }
    print "</table>";
    mysql_free_result($result);
    mysql_close($link);
    ?>

Comments

  (40)  RSS
Hawkee
Comments: 1,122
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Nov 14, 2008
Neat, but which version of phpBB is this compatible with? Also it's always best to do your HTML separate from your PHP code so you don't need to backslash all those quotes.
Xpl0reR
Comments: 254
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Nov 14, 2008
is it working on phpbb2 ?
LordHawk
Comments: 30
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Nov 15, 2008
I wrote this for phpBB3 , its currently not compatible with phpBB2 but I can make a version for phpBB2 if you need one Xpl0reR. I think i might add a marquee to it also for scrolling purposes if you would like that.
Xpl0reR
Comments: 254
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Nov 16, 2008
well, if you could do one for mirc, ( if its easyest, let me know )

something like this

<r00tb0y> New post on mircscripting forum ( http://mircscripting.info/forum ): date: Sun Nov 16, 2008 1:47 am - Forum: Snippets - Title: Private Messages Tip - User: XploreR - text: nice one Xaifas... - link: http://mircscripting.info/forum/viewtopic.php?p=3386#3386

That posts on a channel the new posts on a phpbb2 forum. and/or phpbb3. ( both would be great :)
F*U*R*B*Y*
Comments: 653
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Dec 05, 2008
http://www.hawkee.com/snippet/5420/ Heres a phpBB2 version of it. Hopefully everyone can really use it.
pdumelle
Comments: 1
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Dec 22, 2008
How do i add this to my index page of my phpbb I made it a file and put it in the root and try to do an include in the overall_footer.html but it is not coming up I also tried to hard code it into that file and no luck

I got the code to work on another page but not on the fourm page
see http://cowplow.com/ it works but http://cowplow.com/plowtalk/ no luck
Hawkee
Comments: 1,122
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Dec 23, 2008
The code does an include from phpbb/config.php so you need to make sure that is in sync with where you put it. If you put it inside phpbb/ then you need to change the include to just "config.php" without the phpbb/
F*U*R*B*Y*
Comments: 653
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Dec 24, 2008
i like how Xpl0rer askes for it in phpBB2, so i wrote one up, and he doesn't comment/rate/like it lol
ODD
Comments: 11
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Dec 27, 2008
gj nice one been looking for it but facing a problem as i need it as a joomla! plugin and i wld love to see one that works with mirc as xpl0rer said
ODD
Comments: 11
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jan 06, 2009
ok important question: inorder to use this script i would ahve to edit my config.php CHMOD (permissions) right? if so, thats a real security exploit!
Hawkee
Comments: 1,122
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jan 06, 2009
You don't need to chmod anything, just include the phpBB config.php.
irchainscriptz
Comments: 125
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jan 06, 2009
I like the snippet but as i can see wont work for ppl on Evo-nuke sites :P but other then that nice snippet there :)
LordHawk
Comments: 30
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jan 07, 2009
thanks for all the nice feedback guys, Sorry for you having to answer the questions Hawkee. My aunt passed away so i was off dealing with family issues.
Hawkee
Comments: 1,122
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jan 07, 2009
Oh no problem LordHawk, happy to help. Sorry about your loss.
Lunarpancake
Comments: 1
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jan 09, 2009
LordHawk im interested in having a forum where I would post news / updates. I would like the complete newest post in this forum to show on my homepage (not forum index) could your code up top be modified to do this?

LordHawk
Comments: 30
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jan 09, 2009
hmm it would take a decent amount of modifying but sure it can be done.
F*U*R*B*Y*
Comments: 653
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jan 09, 2009
not really.... just have a truncate function, then just call it upon command :S

quite simple...
PsychoJosh
Comments: 1
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jan 29, 2009
LordHawk
Comments: 30
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Feb 02, 2009
There is a nice news system that can be arranged like that its called Fusion news.
popcorn
Comments: 1
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Mar 12, 2009
How can this be used for a page that use iframe to show the forum??
I want to show my visitors the last 5 posts on my website. But i cant get the iframe to show the latest post. It only opens up the forum in full.

Problem is that i first have to address the page containing the iframe, then the iframe have to be called to open the correct post. How to do this??
hawkeeuser
Comments: 4
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted May 09, 2009
simply use the iframe with link separate page of this script
mbartelt
Comments: 1
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jun 07, 2009
What must I change to show only new posts from a part of the forum? My forum has different boards about HiFi/Homecinema, Games, Fischertechnik and Hiking. So I only want to show new posts in the Hiking part.

Thanks

Manfred
websiteministries
Comments: 1
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jun 22, 2009
Awesome script. Exactly what I was looking for! A+++++++ I hardly ever sign up for forums, but I signed up just so that I could thank you and rate this script.
Eepeepee
Comments: 1
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jun 23, 2009
Nice!

Just one little thing: the script does not produce valid html (any version)

The font and bold tags get opened inside the <td>, but closed outside it (</td></font></b>). It's no biggie since anyone that cares probably knows how to fix it, but still I wanted to bring it up. Also you could add some line breaks there for improved readability.

But yeah anyway, thanks a bunch, the snippet was a great help to me. :)
scotty2024
Comments: 2
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jul 14, 2009
Is there a way to exclude certain forums or even categories? For example, I have a moderator category with three different forums that I don't want displayed. How can I exclude them?
Thanks.
Hawkee
Comments: 1,122
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jul 14, 2009
scotty2024, you probably have to explicity indicate this in the SQL query. Maybe add something like "AND f.forum_id != 123 AND f.forum_id !=234" etc.
scotty2024
Comments: 2
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jul 14, 2009
Never mind, figured it out. For anyone else wanting to do this, change the query to something like this:

$query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
WHERE t.topic_id = p.topic_id AND
f.forum_id = t.forum_id AND
t.forum_id <> X AND
t.topic_status <> 2 AND
p.post_id = t.topic_last_post_id AND
p.poster_id = u.user_id AND
ORDER BY p.post_id DESC LIMIT $topicnumber";

Note the line "t.forum_id <> X AND". Change X to the number of the forum. This number can be found by looking at the URL of the forum. It is f=X in the URL. For example http://www.yourwebsite.com/viewforum.php?f=5. In this case it is 5. You can repeat the line t.forum_id <> X AND for each for you want excluded.
LordHawk
Comments: 30
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jul 14, 2009
Correct Scotty. Sorry ive been really busy, with my site and trying to keep up with the changing times.
VinX
Comments: 70
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Jul 31, 2009
i would really love to see a vBulletin version ..
LordHawk
Comments: 30
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Aug 01, 2009
Im currently working on a SMF version of this same code. I can look into vBulletin also.
VinX
Comments: 70
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Aug 02, 2009
sweet , thanks LordHawk <3
smarta
Comments: 2
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Feb 24, 2010
this works well & is really easy to use - but I have 2 questions

I have a BB that will eventually have many Categories & Forums - is there a way to automatically include forums into the latest post snippet without having to add each form or forum number into the code?

also is there a way I can remove the username & date from the snippet - so just the post's topic appears
WarrenR
Comments: 1
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Mar 09, 2010
my original config.php states:

<?php
// phpBB 3.0.x auto-generated configuration file
// Do not change anything in this file!
$dbms = 'mysqli';
$dbhost = 'localhost';
$dbport = '';
$dbname = 'fatewhee_BBS';
$dbuser = 'fatewhee_WarrenR';
$dbpasswd = 'Haonan_6996';
$table_prefix = 'phpbb_';
$acm_type = 'file';
$load_extensions = '';

@define('PHPBB_INSTALLED', true);
// @define('DEBUG', true);
// @define('DEBUG_EXTRA', true);
?>

where should i insert the code in this original code?

and also, how can i make it display on my home page (in a content box that i create), since i've only changed the config.php for the forum, i think i'd need an additional step to call it up in my homepage?

Sorry, really dump about programming and coding etc.
F*U*R*B*Y*
Comments: 653
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Mar 09, 2010
add the code to where you want it to appear
Korvin
Comments: 421
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Mar 11, 2010
Code:
t.forum_id != 4
not every forum's mod forum has the id 4 =p
smarta
Comments: 2
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Mar 15, 2010
can anyone help me with these questions please ?

I have a BB that will eventually have many Categories & Forums - is there a way to automatically include forums into the latest post snippet without having to add each forum or forum number into the code?

also is there a way I can remove the username & date from the snippet - so just the post's topic appears
Dunc
Comments: 3
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Mar 30, 2010
Hi there, Great script! However I see one problem for anyone that moderates comments before they are put live. The unapproved comments show up on the pages running this script. Is there a way to ensure they cannot be seen until approved? Thanks.
Dunc
Comments: 3
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Apr 07, 2010
I've done some research and to prevent unapproved posts appearing in your list add the following:

t.topic_approved = 1 AND

Dunc
Comments: 3
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted Apr 10, 2010
To set the correct timezone in the script add this line after ORDER BY...

date_default_timezone_set('Europe/London');
iPirate
Comments: 1
 
PHP Snippet:  Latest post on your homepage ( phpbb )
Posted May 13, 2010
How to show only 1 forum? Besides by excluding every other forum XD

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  

Bottom