Code: Select all
<?php
/******************************************************************************
* POST SYNDICATION SCRIPT by chAos
*
* A very basic script that pulls threads with the first post from the database
* and puts them into an array form so you can use them as you like.
*
* For use with phpBB3, freely distributable
*
******************************************************************************/
/** Notes:
*
* - Attachments haven't been handled properly.
* - Starts a forum session as Guest user, taking all the default values for time, bbcode style (from theme), etc
* - While viewing this page, users will appear to be viewing the Forum Index on viewonline.php.
* This can't be helped without modifying other code which is beyond this
*
*/
//////////////////////////////////////
//
define('FORUM_ID', 7); // Forum ID to get data from
define('POST_LIMIT', 3); // How many to get
define('PHPBB_ROOT_PATH', './'); // Path to phpBB (including trailing /)
define('PRINT_TO_SCREEN', true);
// If set to true, it will print the posts out
// If set to false it will create an array $news[] with all the following info
//
// 'topic_id' eg. 119
//
// 'topic_time' eg. 06 June, 07 (uses board default)
// 'topic_replies' eg. 26
//
// 'username' eg. chAos
// 'topic_title' eg. "News Post"
//
// 'post_text' eg. just the text (formatted w/ smilies, bbcode, etc)
//
//////////////////////////////////////
define('IN_PHPBB', true);
$phpbb_root_path = PHPBB_ROOT_PATH;
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
// Start session management
$user->session_begin(false);
$auth->acl($user->data);
// Grab user preferences
$user->setup();
$query =
"SELECT u.user_id, u.username, t.topic_title, t.topic_poster, t.forum_id, t.topic_id, t.topic_last_post_time, t.topic_replies, t.topic_first_post_id, p.poster_id, p.topic_id, p.post_id, p.post_text, p.bbcode_bitfield, p.bbcode_uid
FROM ".USERS_TABLE." u, ".TOPICS_TABLE." t, ".POSTS_TABLE." p
WHERE u.user_id = t.topic_poster
AND u.user_id = p.poster_id
AND t.topic_id = p.topic_id
AND p.post_id = t.topic_first_post_id
AND t.forum_id = ".FORUM_ID."
ORDER BY t.topic_last_post_time DESC";
$result = $db->sql_query_limit($query, POST_LIMIT);
$posts = array();
$news = array();
$bbcode_bitfield = '';
$message = '';
$poster_id = 0;
while ($r = $db->sql_fetchrow($result))
{
$posts[] = array(
'topic_id' => $r['topic_id'],
'topic_last_post_time' => $r['topic_last_post_time'],
'username' => $r['username'],
'topic_title' => $r['topic_title'],
'post_text' => $r['post_text'],
'bbcode_uid' => $r['bbcode_uid'],
'bbcode_bitfield' => $r['bbcode_bitfield'],
'topic_replies' => $r['topic_replies'],
);
$bbcode_bitfield = $bbcode_bitfield | base64_decode($r['bbcode_bitfield']);
}
// Instantiate BBCode
if ($bbcode_bitfield !== '')
{
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}
// Output the posts
foreach($posts as $m)
{
$poster_id = $m['user_id'];
$message = $m['post_text'];
if($m['bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($message, $m['bbcode_uid'], $m['bbcode_bitfield']);
}
$message = str_replace("\n", '<br />', $message);
$message = smiley_text($message);
$comment = ($m['topic_replies']==1) ? 'comment' : 'comments';
if( PRINT_TO_SCREEN )
{
/* Output is in the following format
*
* <h3>Thread Title</h3>
^ <h4 class="postinfo">date // 5 comments // poster</h4>
* <p>First post test</p>
*
*/
echo "\n\n<h3>{$m['topic_title']}</h3>";
echo "\n<h4 class=\"postinfo\">".$user->format_date($m['topic_last_post_time'])." // <a href=\"".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$m['topic_id']}\">{$m['topic_replies']} {$comment}</a> // {$m['username']}</h4>";
echo "\n<p>{$message}</p>";
}
else
{
$news[] = array(
'topic_last_post_time' => $user->format_date($m['topic_last_post_time']), // eg: 06 June, 07 (uses board default)
'topic_id' => $m['topic_id'], // eg: 119
'topic_replies' => $m['topic_replies'], // eg: 26
'username' => $m['username'], // eg: chAos
'topic_title' => $m['topic_title'], // eg: "News Post"
'post_text' => $message, // just the text
);
}
unset($message,$poster_id);
}
?>
thanks dude! Amazing!SpongeWeb wrote:ooooh I just did it!
I created a POSTTOPICS variable,Code: Select all
//news on home define('FORUM_ID', 10); // Forum ID to get data from define('POST_LIMIT', 2); // How many to get define('PHPBB_ROOT_PATH', './spongeboard/'); // Path to phpBB (including trailing /) define('PRINT_TO_SCREEN', true); // Start session management $user->session_begin(false); $auth->acl($user->data); // Grab user preferences $user->setup(); $query = "SELECT u.user_id, u.username, t.topic_title, t.topic_poster, t.forum_id, t.topic_id, t.topic_time, t.topic_replies, t.topic_first_post_id, p.poster_id, p.topic_id, p.post_id, p.post_text, p.bbcode_bitfield, p.bbcode_uid FROM ".USERS_TABLE." u, ".TOPICS_TABLE." t, ".POSTS_TABLE." p WHERE u.user_id = t.topic_poster AND u.user_id = p.poster_id AND t.topic_id = p.topic_id AND p.post_id = t.topic_first_post_id AND t.forum_id = ".FORUM_ID." ORDER BY t.topic_time DESC"; $result = $db->sql_query_limit($query, POST_LIMIT); $posts = array(); $news = array(); $bbcode_bitfield = ''; $message = ''; $poster_id = 0; while ($r = $db->sql_fetchrow($result)) { $posts[] = array( 'topic_id' => $r['topic_id'], 'topic_time' => $r['topic_time'], 'username' => $r['username'], 'topic_title' => $r['topic_title'], 'post_text' => $r['post_text'], 'bbcode_uid' => $r['bbcode_uid'], 'bbcode_bitfield' => $r['bbcode_bitfield'], 'topic_replies' => $r['topic_replies'], ); $bbcode_bitfield = $bbcode_bitfield | base64_decode($r['bbcode_bitfield']); } // Instantiate BBCode if ($bbcode_bitfield !== '') { $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } // Output the posts foreach($posts as $m) { $poster_id = $m['user_id']; $message = $m['post_text']; if($m['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $m['bbcode_uid'], $m['bbcode_bitfield']); } $message = str_replace("\n", '<br />', $message); $message = smiley_text($message); $comment = ($m['topic_replies']==1) ? 'comment' : 'comments'; if( PRINT_TO_SCREEN ) { /* Output is in the following format * * <h3>Thread Title</h3> ^ <h4 class="postinfo">date // 5 comments // poster</h4> * <p>First post test</p> * */ { $postpage .= "\n\n<h3>{$m['topic_title']}</h3> \n<h4 class=\"postinfo\">".$user->format_date($m['topic_time'])." // <a href=\"".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$m['topic_id']}\">{$m['topic_replies']} {$comment}</a> // {$m['username']}</h4> \n<p>{$message}</p>"; }} else { $news[] = array( 'topic_id' => $m['topic_id'], // eg: 119 'topic_time' => $user->format_date($m['topic_time']), // eg: 06 June, 07 (uses board default) 'topic_replies' => $m['topic_replies'], // eg: 26 'username' => $m['username'], // eg: chAos 'topic_title' => $m['topic_title'], // eg: "News Post" 'post_text' => $message, // just the text ); } unset($message,$poster_id); } $template->assign_vars(array( 'POSTTOPICS' => $postpage,) );
then in my template I just added {POSTTOPICS} AND BINGO!!
Everything displays fine, How do I remove the debug?[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home/c809391/public_html/index.php:6)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home/c809391/public_html/index.php:6)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home/c809391/public_html/index.php:6)
Code: Select all
define('FORUM_ID', 17); // Forum ID to get data from
define('POST_LIMIT', 7); // How many to get
define('PHPBB_ROOT_PATH', './phpbb/'); // Path to phpBB (including trailing /)
Code: Select all
?>
include("news.php");
?>
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="generator" content="SiteGrinder 2 http://www.medialab.com/sitegrinder" />
<title>Home</title>
<link rel="stylesheet" type="text/css" media="screen, print, projection" href="common.css"></link>
<style type="text/css">
h5 {color:#009;}
</style>
</head>
<body>
<?php
/******************************************************************************
* POST SYNDICATION SCRIPT by chAos
*
* A very basic script that pulls threads with the first post from the database
* and puts them into an array form so you can use them as you like.
*
* For use with phpBB3, freely distributable
*
******************************************************************************/
/** Notes:
*
* - Attachments haven't been handled properly.
* - Starts a forum session as Guest user, taking all the default values for time, bbcode style (from theme), etc
* - While viewing this page, users will appear to be viewing the Forum Index on viewonline.php.
* This can't be helped without modifying other code which is beyond this
*
*/
//////////////////////////////////////
//
define('FORUM_ID', 2); // Forum ID to get data from
define('POST_LIMIT', 1); // How many to get
define('PHPBB_ROOT_PATH', './forum/'); // Path to phpBB (including trailing /)
define('PRINT_TO_SCREEN', true);
global $db;
// If set to true, it will print the posts out
// If set to false it will create an array $news[] with all the following info
//
// 'topic_id' eg. 119
//
// 'topic_time' eg. 06 June, 07 (uses board default)
// 'topic_replies' eg. 26
//
// 'username' eg. chAos
// 'topic_title' eg. "News Post"
//
// 'post_text' eg. just the text (formatted w/ smilies, bbcode, etc)
//
//////////////////////////////////////
define('IN_PHPBB', true);
$phpbb_root_path = PHPBB_ROOT_PATH;
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
?>
<div id="felloship">
<div id="layer5"></div>
<div id="id2bg"></div>
<div id="top"></div>
<div id="oval"></div>
<div id="layer27"></div>
<div id="layer24"></div>
<div id="layer22"></div>
<div id="journeyoffaithfellowshipg"></div>
<div id="wherenoonewalksaloneg"></div>
<div id="wherenoonewalksalonecopyg"></div>
<div id="journeyoffaithfellowshipcopyg"></div>
<div id="foreventhesonofmanjesug"></div>
<div id="mark1045g"></div>
<div id="id30bg"></div>
<div id="contactbutton"><a href="contact.html" title="Contact"></a></div>
<div id="homebutton"><a href="index.html" title="Home"></a></div>
<div id="aboutbutton"><a href="about.html" title="About"></a></div>
<div id="forumbutton"><a href="forum.html" title="Forum"></a></div>
<div id="picturesbutton"><a href="pictures.html" title="Pictures"></a></div>
<div id="musicbutton"><a href="music.html" title="Music"></a></div>
<div id="videobutton"><a href="video.html" title="Video"></a></div>
<div id="layer3"></div>
<div id="id8loremipsumdolorsitametcotext">
<?php
$user->session_begin(false);
$auth->acl($user->data);
// Grab user preferences
$user->setup();
$query =
"SELECT u.user_id, u.username, t.topic_title, t.topic_poster, t.forum_id, t.topic_id, t.topic_time, t.topic_replies, t.topic_first_post_id, p.poster_id, p.topic_id, p.post_id, p.post_text, p.bbcode_bitfield, p.bbcode_uid
FROM ".USERS_TABLE." u, ".TOPICS_TABLE." t, ".POSTS_TABLE." p
WHERE u.user_id = t.topic_poster
AND u.user_id = p.poster_id
AND t.topic_id = p.topic_id
AND p.post_id = t.topic_first_post_id
AND t.forum_id = ".FORUM_ID."
ORDER BY t.topic_time DESC";
$result = $db->sql_query_limit($query, POST_LIMIT);
$posts = array();
$news = array();
$bbcode_bitfield = '';
$message = '';
$poster_id = 0;
while ($r = $db->sql_fetchrow($result))
{
$posts[] = array(
'topic_id' => $r['topic_id'],
'topic_time' => $r['topic_time'],
'username' => $r['username'],
'topic_title' => $r['topic_title'],
'post_text' => $r['post_text'],
'bbcode_uid' => $r['bbcode_uid'],
'bbcode_bitfield' => $r['bbcode_bitfield'],
'topic_replies' => $r['topic_replies'],
);
$bbcode_bitfield = $bbcode_bitfield | base64_decode($r['bbcode_bitfield']);
}
// Instantiate BBCode
if ($bbcode_bitfield !== '')
{
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}
// Output the posts
foreach($posts as $m)
{
$poster_id = $m['user_id'];
$message = $m['post_text'];
if($m['bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($message, $m['bbcode_uid'], $m['bbcode_bitfield']);
}
$message = str_replace("\n", '<br />', $message);
$message = smiley_text($message);
$comment = ($m['topic_replies']==1) ? 'comment' : 'comments';
if( PRINT_TO_SCREEN )
{
/* Output is in the following format
*
* <h3>Thread Title</h3>
^ <h4 class="postinfo">date // 5 comments // poster</h4>
* <p>First post test</p>
*
*/
echo "\n\n<h5>{$m['topic_title']}</h5>";
echo "\n<p>{$message}</p>";
echo "\n<h6 class=\"postinfo\">".$user->format_date($m['topic_time'])." // <a href=\"".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$m['topic_id']}\">{$m['topic_replies']} {$comment}</a> // {$m['username']}</h6>";
}
else
{
$news[] = array(
'topic_id' => $m['topic_id'], // eg: 119
'topic_title' => $m['topic_title'], // eg: "News Post"
'post_text' => $message, // just the text
'topic_time' => $user->format_date($m['topic_time']), // eg: 06 June, 07 (uses board default)
'topic_replies' => $m['topic_replies'], // eg: 26
'username' => $m['username'], // eg: chAos
);
}
unset($message,$poster_id);
}
?>
</div>
<div id="sep"></div>
<div id="id9loremipsumdolorsitametcotext">
<p>PHPBB EVENT FEED.</p>
<br />
<p>PHP EVENT FEED OR SOMETHING </p>
</div>
<div id="layer2"></div>
<div id="conceptbymattwillcoxdesitext">
<p>concept by: <span style="color:#A6D4F5;">Matt Wilcox</span> Design by <span style="color:#A6D4F5;">dom haynes</span></p>
</div>
</div>
</body>
</html>
The problem is you can't have anything printed before you post the news (in your case you have HTML). To solve this put the news code at the top of the page, but then print the array of news in the position you actually want it to appear.MattBamm wrote:Hello,
I have just about read every post and have done some of the stuff suggested but I cannot get this PHP Debug crap to go away.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home/ohgaming/public_html/index.php:7)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home/ohgaming/public_html/index.php:7)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home/ohgaming/public_html/index.php:7)
Any help would be greatly appreciated.
View my site @ http://MyJoff.com
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> <meta name="generator" content="SiteGrinder 2 http://www.medialab.com/sitegrinder" /> <title>Home</title> <link rel="stylesheet" type="text/css" media="screen, print, projection" href="common.css"></link> <style type="text/css"> h5 {color:#009;} </style> </head> <body> <?php /****************************************************************************** * POST SYNDICATION SCRIPT by chAos * * A very basic script that pulls threads with the first post from the database * and puts them into an array form so you can use them as you like. * * For use with phpBB3, freely distributable * ******************************************************************************/ /** Notes: * * - Attachments haven't been handled properly. * - Starts a forum session as Guest user, taking all the default values for time, bbcode style (from theme), etc * - While viewing this page, users will appear to be viewing the Forum Index on viewonline.php. * This can't be helped without modifying other code which is beyond this * */ ////////////////////////////////////// // define('FORUM_ID', 2); // Forum ID to get data from define('POST_LIMIT', 1); // How many to get define('PHPBB_ROOT_PATH', './forum/'); // Path to phpBB (including trailing /) define('PRINT_TO_SCREEN', true); global $db; // If set to true, it will print the posts out // If set to false it will create an array $news[] with all the following info // // 'topic_id' eg. 119 // // 'topic_time' eg. 06 June, 07 (uses board default) // 'topic_replies' eg. 26 // // 'username' eg. chAos // 'topic_title' eg. "News Post" // // 'post_text' eg. just the text (formatted w/ smilies, bbcode, etc) // ////////////////////////////////////// define('IN_PHPBB', true); $phpbb_root_path = PHPBB_ROOT_PATH; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($phpbb_root_path . 'includes/bbcode.' . $phpEx); ?> <div id="felloship"> <div id="layer5"></div> <div id="id2bg"></div> <div id="top"></div> <div id="oval"></div> <div id="layer27"></div> <div id="layer24"></div> <div id="layer22"></div> <div id="journeyoffaithfellowshipg"></div> <div id="wherenoonewalksaloneg"></div> <div id="wherenoonewalksalonecopyg"></div> <div id="journeyoffaithfellowshipcopyg"></div> <div id="foreventhesonofmanjesug"></div> <div id="mark1045g"></div> <div id="id30bg"></div> <div id="contactbutton"><a href="contact.html" title="Contact"></a></div> <div id="homebutton"><a href="index.html" title="Home"></a></div> <div id="aboutbutton"><a href="about.html" title="About"></a></div> <div id="forumbutton"><a href="forum.html" title="Forum"></a></div> <div id="picturesbutton"><a href="pictures.html" title="Pictures"></a></div> <div id="musicbutton"><a href="music.html" title="Music"></a></div> <div id="videobutton"><a href="video.html" title="Video"></a></div> <div id="layer3"></div> <div id="id8loremipsumdolorsitametcotext"> <?php $user->session_begin(false); $auth->acl($user->data); // Grab user preferences $user->setup(); $query = "SELECT u.user_id, u.username, t.topic_title, t.topic_poster, t.forum_id, t.topic_id, t.topic_time, t.topic_replies, t.topic_first_post_id, p.poster_id, p.topic_id, p.post_id, p.post_text, p.bbcode_bitfield, p.bbcode_uid FROM ".USERS_TABLE." u, ".TOPICS_TABLE." t, ".POSTS_TABLE." p WHERE u.user_id = t.topic_poster AND u.user_id = p.poster_id AND t.topic_id = p.topic_id AND p.post_id = t.topic_first_post_id AND t.forum_id = ".FORUM_ID." ORDER BY t.topic_time DESC"; $result = $db->sql_query_limit($query, POST_LIMIT); $posts = array(); $news = array(); $bbcode_bitfield = ''; $message = ''; $poster_id = 0; while ($r = $db->sql_fetchrow($result)) { $posts[] = array( 'topic_id' => $r['topic_id'], 'topic_time' => $r['topic_time'], 'username' => $r['username'], 'topic_title' => $r['topic_title'], 'post_text' => $r['post_text'], 'bbcode_uid' => $r['bbcode_uid'], 'bbcode_bitfield' => $r['bbcode_bitfield'], 'topic_replies' => $r['topic_replies'], ); $bbcode_bitfield = $bbcode_bitfield | base64_decode($r['bbcode_bitfield']); } // Instantiate BBCode if ($bbcode_bitfield !== '') { $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } // Output the posts foreach($posts as $m) { $poster_id = $m['user_id']; $message = $m['post_text']; if($m['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $m['bbcode_uid'], $m['bbcode_bitfield']); } $message = str_replace("\n", '<br />', $message); $message = smiley_text($message); $comment = ($m['topic_replies']==1) ? 'comment' : 'comments'; if( PRINT_TO_SCREEN ) { /* Output is in the following format * * <h3>Thread Title</h3> ^ <h4 class="postinfo">date // 5 comments // poster</h4> * <p>First post test</p> * */ echo "\n\n<h5>{$m['topic_title']}</h5>"; echo "\n<p>{$message}</p>"; echo "\n<h6 class=\"postinfo\">".$user->format_date($m['topic_time'])." // <a href=\"".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$m['topic_id']}\">{$m['topic_replies']} {$comment}</a> // {$m['username']}</h6>"; } else { $news[] = array( 'topic_id' => $m['topic_id'], // eg: 119 'topic_title' => $m['topic_title'], // eg: "News Post" 'post_text' => $message, // just the text 'topic_time' => $user->format_date($m['topic_time']), // eg: 06 June, 07 (uses board default) 'topic_replies' => $m['topic_replies'], // eg: 26 'username' => $m['username'], // eg: chAos ); } unset($message,$poster_id); } ?> </div> <div id="sep"></div> <div id="id9loremipsumdolorsitametcotext"> <p>PHPBB EVENT FEED.</p> <br /> <p>PHP EVENT FEED OR SOMETHING </p> </div> <div id="layer2"></div> <div id="conceptbymattwillcoxdesitext"> <p>concept by: <span style="color:#A6D4F5;">Matt Wilcox</span> Design by <span style="color:#A6D4F5;">dom haynes</span></p> </div> </div> </body> </html>