Total Users Online: 2





PHPBB: Display replies from posts on external pages

MySQL/PHP/Java/AXAJ etc. short tutorials or code snippets good to go usage.

PHPBB: Display replies from posts on external pages

Postby yang » Sun Mar 01, 2009 6:21 pm

This is lil something I made myself because I needed to get replies from posts/threads in frontpage as you can see the comments.

A few things to know before progressing.


We are assuming you already have articles showing on external pages. If not read through this http://www.phpbb.com/community/viewtopic.php?f=71&t=587812&hilit=picture+attachments&start=645

This is what you would add to the OUTPUT step of any of the previous methods mentioned on there but please please realize this is just the core, you will have to tweak it in order to get it working with your news script or post here for help from me.

So the basic mysql step is:

Code: Select all
$replies_query = "
SELECT poster_id, post_text, post_time
FROM phpbb_posts
WHERE topic_id = " . $post[topic_id] . "
AND post_subject LIKE 'Re:%'
ORDER BY post_time DESC
LIMIT 0 , 30
";

//die('<pre>' . $query );
$replies_query = $db->sql_query( $replies_query );


Then to output the data:

Code: Select all
while( $replies_row = $db->sql_fetchrow($replies_query) )
{

   $phpbb_root_path = '/forums/';
   $phpbb_root_path = $_SERVER['DOCUMENT_ROOT'] . '/forums/';

   // Send data to output var
   $reply_output .= date("M d, Y - g:ia", $replies_row['post_time']) . " - " . $replies_row['poster_id'];
   $reply_output .= $replies_row['post_text'] . "<br />";
   $reply_output .= '<br />';
}

// print the output
print( $reply_output );


To get the poster_id into the actual username use:
Code: Select all
$reply_username   = get_username_string('username', $replies_row['poster_id'], 0);
echo $reply_username;


This is the basic core. Just add these code to your output area and change the valuables if the valuables are different and it will work :)

Happy Days!

Since every forum news/thread display differently on external pages and use different script to achieve that, this is just a simple nudge in the right direction if you don't know how to get there.
"To know, is to know that you know nothing. That is the meaning of true knowledge." - Confucius
"知之为知之,不知为不知,是知也。" - 孔子
User avatar
yang
The Big Kahuna
 
Posts: 68
Joined: Thu Jul 31, 2008 12:02 am
Location: Portland, OR

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 0 guests

cron