Front Page News Syndication

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in the Customisations Database.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
cakes
Registered User
Posts: 6
Joined: Sat Jan 16, 2010 6:10 am

Re: Front Page News Syndication

Post by cakes » Sat Jan 16, 2010 5:20 pm

Hey. In my news script in displaying only two topics. I want a horizontal rule between the two of them, but if i add <hr>, it appears below both of the topics, but I just want one in the middle. How do i do this?

Luis_G
Registered User
Posts: 2
Joined: Sun Jan 17, 2010 6:07 am

Re: Front Page News Syndication

Post by Luis_G » Sun Jan 17, 2010 6:18 am

Hi, I've already installed this MOD, and it's ok so far... I've modified the code so I have the news ordered by last posts first (not necessarily last topics)... the problem is I couldn't associate last post to last poster, so I always get the original poster in my news (the one who submitted the topic at first)...

this is my code, I don't know which line I have to modify

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);
}

?>

User avatar
trickoff
Registered User
Posts: 513
Joined: Mon Jan 07, 2008 12:23 am

Re: Front Page News Syndication

Post by trickoff » Mon Jan 18, 2010 12:40 am

SpongeWeb wrote:ooooh I just did it!

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,)
);
I created a POSTTOPICS variable,
then in my template I just added {POSTTOPICS} AND BINGO!!
thanks dude! Amazing!

Luis_G
Registered User
Posts: 2
Joined: Sun Jan 17, 2010 6:07 am

Re: Front Page News Syndication

Post by Luis_G » Wed Jan 20, 2010 10:23 pm

Solved!!!!.... thanks anyway, it was just a really stupid newbie mistake

User avatar
crawlerbasher
Registered User
Posts: 18
Joined: Sat Jan 05, 2008 4:03 am
Location: UK
Contact:

Re: Front Page News Syndication

Post by crawlerbasher » Tue Jan 26, 2010 2:32 am

I've tryed using this but it dose not work.
When trying this:
define('PRINT_TO_SCREEN', true);
and use on my index.php page require("news.php");
it pops up with number of error about session and header already been called.

[phpBB Debug] PHP Notice: in file /includes/session.php on line 1006: Cannot modify header information - headers already sent by (output started at /home/cra10002/public_html/header.php:4)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1006: Cannot modify header information - headers already sent by (output started at /home/cra10002/public_html/header.php:4)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1006: Cannot modify header information - headers already sent by (output started at /home/cra10002/public_html/header.php:4)

So I changed it to

define('PRINT_TO_SCREEN', false);

and then placed it before require("header.php");

but when I try use echo $news['post_text'];
and others like from the instrction in the news.php file
there is notthing been outputed.
yet if I use somthing like this echo $m['username']; execpt for the $comment.

Why dose it keep poping up with the error message when I try it the first time.
And why does notthing apper when trying to echo $news?

Its kind of pointless having this if it only works with out the use of the header.
Time is an illusion. Lunchtime, doubly so.

User avatar
crawlerbasher
Registered User
Posts: 18
Joined: Sat Jan 05, 2008 4:03 am
Location: UK
Contact:

Re: Front Page News Syndication

Post by crawlerbasher » Tue Jan 26, 2010 3:15 am

never mind got it working, after back trackign though all this post.

BTW how can I add the avatar image of the poster to it too?
Time is an illusion. Lunchtime, doubly so.

jdsimonds
Registered User
Posts: 4
Joined: Wed Feb 10, 2010 10:07 pm

Re: Front Page News Syndication

Post by jdsimonds » Wed Feb 17, 2010 8:12 am

This is a great mod, But i have one question. Is there anyway to make attached images show?

If not that is fine, We just want to attach images and not have to link to the url.

Thanks!

sammjj
Registered User
Posts: 2
Joined: Sat Jun 13, 2009 10:46 am

Re: Front Page News Syndication

Post by sammjj » Thu Feb 18, 2010 7:59 pm

I get a debug error at the top of every page :S :cry:
[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)
Everything displays fine, How do I remove the debug?

chriscooney
Registered User
Posts: 3
Joined: Tue Mar 09, 2010 2:32 pm

Re: Front Page News Syndication

Post by chriscooney » Tue Mar 09, 2010 2:38 pm

Hello,

Sorry to be a bit of a pain/newbie but i'd like some help if possible. I've played with some php changing and such before but i'm a little lost here.

I've changed my news.php to contain;

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 /)
From here i've uploaded it to a folder where all my web bits are, the next folder down contains the phpbb forum, so i've set the root_patch as /phpbb/.

Now is where i think ive lost myself.

The forum id i want to use as my "news" forum is with ID 17.

I have an index.php file which im trying to play with to come to terms with what it is im attempting to do; but this is where i'm lost.

I believe i need to call the news.php file, to do this i need to put at the top of it;

Code: Select all

?>
include("news.php");
?>
Is this correct?

From here, im not entirely sure how i am to go about displaying the content, so any help from this point on would be superb.

Thanks.

chriscooney
Registered User
Posts: 3
Joined: Tue Mar 09, 2010 2:32 pm

Re: Front Page News Syndication

Post by chriscooney » Tue Mar 09, 2010 3:11 pm

OK so i have made some progress from my intitial post.

I stuck the include for news.php in and discovered it output my posts from the forum at the location on the page where i was calling news.php, but with the debug message several people have asked about. The general response is if you're interegrating it with an existing page, which i am, put everything up to and including line 59 at the top of your page.

Question; does this mean i copy and paste everything and including line59 of the news.php file into my index.php file to the top of the page? And then line 60 onwards to the location of where i wish the news to go?

Im a confused :D

Thanks in advance.

chriscooney
Registered User
Posts: 3
Joined: Tue Mar 09, 2010 2:32 pm

Re: Front Page News Syndication

Post by chriscooney » Tue Mar 09, 2010 3:16 pm

Ok so through trial and error i've fixed this myself, go me :D

MattBamm
Registered User
Posts: 1
Joined: Mon Apr 05, 2010 3:11 pm

Re: Front Page News Syndication

Post by MattBamm » Mon Apr 05, 2010 3:15 pm

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>

User avatar
chAos
Former Team Member
Posts: 4032
Joined: Wed Jan 16, 2002 7:05 am
Location: Seattle, WA, US

Re: Front Page News Syndication

Post by chAos » Mon Apr 05, 2010 11:11 pm

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>
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.

Locked

Return to “[3.0.x] MOD Database Releases”

Who is online

Users browsing this forum: No registered users and 18 guests

cron