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.
Locked
User avatar
nicke157
Registered User
Posts: 48
Joined: Sun Nov 09, 2008 11:02 pm
Contact:

Re: Front Page News Syndication

Post by nicke157 »

I don't get any news at the home.php. I only get the text "Test". What i have did wrong?

This is my files:

news.php

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', 3);                    // Forum ID to get data from
    define('POST_LIMIT', 8);                  // 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 . 'includes/functions_display.' . $phpEx);
    include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
    global $db;

    // Start session management
    $user->session_begin(false);


    // 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<h3>{$m['topic_title']}</h3>";
          echo "\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>";
          echo "\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);
    }

    // Output page
    page_header($user->lang['INDEX']);



?>
home.php

Code: Select all

<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('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();
    $auth->acl($user->data);
    $user->setup();

    page_header('Test');

    $template->set_filenames(array(
        'body' => 'home_body.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();
?>
home_body.html

Code: Select all

<!-- INCLUDE overall_header.html -->

    <h2>Test</h2>

    <div class="panel">
       <div class="inner"><span class="corners-top"><span></span></span>

       <div class="content">
          <p>
             <!-- PHP --> include("/news.php"); <!-- ENDPHP -->
          </p>
       </div>

       <span class="corners-bottom"><span></span></span></div>
    </div>

    <!-- INCLUDE jumpbox.html -->
    <!-- INCLUDE overall_footer.html -->
mnematv
Registered User
Posts: 6
Joined: Sat Apr 04, 2009 10:48 am

Re: Front Page News Syndication

Post by mnematv »

The mod works fine for me in English, however my forum is in the Russian language, and when topics/text is in Russian it outputs gibberish. Any suggestions? Thanks!
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 »

nicke157 wrote:I don't get any news at the home.php. I only get the text "Test". What i have did wrong?

This is my files:

news.php

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', 3);                    // Forum ID to get data from
    define('POST_LIMIT', 8);                  // 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 . 'includes/functions_display.' . $phpEx);
    include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
    global $db;

    // Start session management
    $user->session_begin(false);


    // 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<h3>{$m['topic_title']}</h3>";
          echo "\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>";
          echo "\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);
    }

    // Output page
    page_header($user->lang['INDEX']);



?>
home.php

Code: Select all

<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('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();
    $auth->acl($user->data);
    $user->setup();

    page_header('Test');

    $template->set_filenames(array(
        'body' => 'home_body.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();
?>
home_body.html

Code: Select all

<!-- INCLUDE overall_header.html -->

    <h2>Test</h2>

    <div class="panel">
       <div class="inner"><span class="corners-top"><span></span></span>

       <div class="content">
          <p>
             <!-- PHP --> include("/news.php"); <!-- ENDPHP -->
          </p>
       </div>

       <span class="corners-bottom"><span></span></span></div>
    </div>

    <!-- INCLUDE jumpbox.html -->
    <!-- INCLUDE overall_footer.html -->
In news.php, try commenting (/* */) this block of code since it's already included in home.php:

Code: Select all

define('IN_PHPBB', true);
    $phpbb_root_path = PHPBB_ROOT_PATH;
    $phpEx = substr(strrchr(__FILE__, '.'), 1);

    include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
    include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
    global $db;

    // Start session management
    $user->session_begin(false);


    // Grab user preferences
    $user->setup();
mnematv wrote:The mod works fine for me in English, however my forum is in the Russian language, and when topics/text is in Russian it outputs gibberish. Any suggestions? Thanks!
Are you sure the page you're using the news on is in UTF-8 encoding?
mnematv
Registered User
Posts: 6
Joined: Sat Apr 04, 2009 10:48 am

Re: Front Page News Syndication

Post by mnematv »

Yes, and everything shows up fine except the output of news.php. You can take a look at http://www.handofhelpministry.com the pink section down the middle of the page outputs the posts. The one in English outputs fine (last one). I even saved news.php in utf-8 but that wont do anything.



----------------Problem solved it wasn't saved as utf-8 after all! Thanks.
mnematv
Registered User
Posts: 6
Joined: Sat Apr 04, 2009 10:48 am

Re: Front Page News Syndication

Post by mnematv »

One more quick question: what code would I need to add to make the title of the topic an active link to the topic. (User can click comments, but I would like to make the title a link as well.)
User avatar
nicke157
Registered User
Posts: 48
Joined: Sun Nov 09, 2008 11:02 pm
Contact:

Re: Front Page News Syndication

Post by nicke157 »

I have fixed my trouble now. It was a space before <!-- INCLUDE overall_header.html -->
and the php-tag :oops:
User avatar
daGrevis
Registered User
Posts: 146
Joined: Sat Jan 10, 2009 7:41 am
Location: Latvia

Re: Front Page News Syndication

Post by daGrevis »

All works just fine, except there isnt output of news... :( Please, help!
All is saved as UTF-8 without BOM, and all confugured correcly, i thing... :) (PHP in templates enabled, correct forum id and root path)
Here is files... Please help, i will be thankful, indeed! :(

news.php

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', 4);                    // Forum ID to get data from
    define('POST_LIMIT', 8);                  // 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 . 'includes/functions_display.' . $phpEx);
    include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
    global $db;

    // Start session management
    $user->session_begin(false);


    // 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<h3>{$m['topic_title']}</h3>";
          echo "\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>";
          echo "\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);
    }

    // Output page
    page_header($user->lang['INDEX']);



?>
home.php

Code: Select all

<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('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();
    $auth->acl($user->data);
    $user->setup();

    page_header('Test');

    $template->set_filenames(array(
        'body' => 'home_body.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();
?>
home_body.html

Code: Select all

<!-- INCLUDE overall_header.html -->

    <h2>News</h2>

    <div class="panel">
       <div class="inner"><span class="corners-top"><span></span></span>

       <div class="content">
          <p>
             <!-- PHP --> include("/news.php"); <!-- ENDPHP -->
          </p>
       </div>

       <span class="corners-bottom"><span></span></span></div>
    </div>

    <!-- INCLUDE jumpbox.html -->
    <!-- INCLUDE overall_footer.html -->
kenerly
Registered User
Posts: 79
Joined: Fri May 23, 2003 6:25 am

Re: Front Page News Syndication

Post by kenerly »

I got it working see here http://www.christiangamers.net/network

however, I have html enabled and the news.php code does not seem to display the html post. Do I need to add code to the news.php so the html works. html works in all other post on the site.
TheRazer
Registered User
Posts: 6
Joined: Sat Apr 11, 2009 3:15 am

Re: Front Page News Syndication

Post by TheRazer »

Hallo... i have phpbb3 3.0.4 and the problem is thet i cant se the news...
i cane only se the home text... here is my code...

news.php

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', 2);                    // Forum ID to get data from
define('POST_LIMIT', 7);                  // 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)

//
//////////////////////////////////////



$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<h3>{$m['topic_title']}</h3>";
      echo "\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>";
      echo "\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);
}

// Output page
page_header($user->lang['INDEX']);



?>
home.php

Code: Select all

<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('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();
    $auth->acl($user->data);
    $user->setup();

    page_header('Test');

    $template->set_filenames(array(
        'body' => 'home_body.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();
?>
home_body.html

Code: Select all

    <!-- INCLUDE overall_header.html -->

    <h2>Home</h2>

    <div class="panel">
       <div class="inner"><span class="corners-top"><span></span></span>

       <div class="content">
<p>
<!-- PHP --> include("/news.php"); <!-- ENDPHP -->
</p>
       </div>

       <span class="corners-bottom"><span></span></span></div>
    </div>

    <!-- INCLUDE jumpbox.html -->
    <!-- INCLUDE overall_footer.html -->
blazin.jc
Registered User
Posts: 1
Joined: Fri Feb 20, 2009 7:43 pm

Re: Front Page News Syndication

Post by blazin.jc »

Hey Chaos I'm have the same trouble as IexcelU and I'm trying to figure out what did I do wrong cuzz the install of the modx went really. Please help me out and thanks in advance.


Warning: include(./forums/common.php) [function.include]: failed to open stream: No such file or directory in /hermes/bosweb/web169/b1699/ipw.dstylezi/public_html/teochiu/forum/news.php on line 50

Warning: include() [function.include]: Failed opening './forums/common.php' for inclusion (include_path='.:/usr/local/lib/php-5.2.4/lib/php') in /hermes/bosweb/web169/b1699/ipw.dstylezi/public_html/teochiu/forum/news.php on line 50

Warning: include(./forums/includes/functions_display.php) [function.include]: failed to open stream: No such file or directory in /hermes/bosweb/web169/b1699/ipw.dstylezi/public_html/teochiu/forum/news.php on line 51

Warning: include() [function.include]: Failed opening './forums/includes/functions_display.php' for inclusion (include_path='.:/usr/local/lib/php-5.2.4/lib/php') in /hermes/bosweb/web169/b1699/ipw.dstylezi/public_html/teochiu/forum/news.php on line 51

Warning: include(./forums/includes/bbcode.php) [function.include]: failed to open stream: No such file or directory in /hermes/bosweb/web169/b1699/ipw.dstylezi/public_html/teochiu/forum/news.php on line 52

Warning: include() [function.include]: Failed opening './forums/includes/bbcode.php' for inclusion (include_path='.:/usr/local/lib/php-5.2.4/lib/php') in /hermes/bosweb/web169/b1699/ipw.dstylezi/public_html/teochiu/forum/news.php on line 52

Fatal error: Call to a member function session_begin() on a non-object in /hermes/bosweb/web169/b1699/ipw.dstylezi/public_html/teochiu/forum/news.php on line 55
TheRazer
Registered User
Posts: 6
Joined: Sat Apr 11, 2009 3:15 am

Re: Front Page News Syndication

Post by TheRazer »

ok... i have fixt it...
in home_body.html i change

Code: Select all

<!-- PHP --> include("/news.php"); <!-- ENDPHP -->
to

Code: Select all

<!-- PHP --> include("news.php"); <!-- ENDPHP -->
and in news.php i added

Code: Select all

global $db;
under

Code: Select all

define('FORUM_ID', 2);                    // Forum ID to get data from
define('POST_LIMIT', 7);                  // How many to get
define('PHPBB_ROOT_PATH', './');   // Path to phpBB (including trailing /)

define('PRINT_TO_SCREEN', true);        
All my code for thos ho hawe the same problem...

news.php

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', 2);                    // Forum ID to get data from
define('POST_LIMIT', 7);                  // 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)

//
//////////////////////////////////////

global $db;

$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<h3>{$m['topic_title']}</h3>";
      echo "\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>";
      echo "\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);
}

// Output page
page_header($user->lang['INDEX']);



?>
home.php

Code: Select all

<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('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();
    $auth->acl($user->data);
    $user->setup();

    page_header('Test');

    $template->set_filenames(array(
        'body' => 'home_body.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();
?>
home_body.html

Code: Select all

    <!-- INCLUDE overall_header.html -->

    <h2>Home</h2>

    <div class="panel">
       <div class="inner"><span class="corners-top"><span></span></span>

       <div class="content">
<p>
<!-- PHP --> include("news.php"); <!-- ENDPHP -->
</p>
       </div>

       <span class="corners-bottom"><span></span></span></div>
    </div>

    <!-- INCLUDE jumpbox.html -->
    <!-- INCLUDE overall_footer.html -->


DogoJosho
Registered User
Posts: 11
Joined: Fri Mar 20, 2009 3:57 am

Re: Front Page News Syndication

Post by DogoJosho »

Hi, ok I got this error when i try to access news.php

Code: Select all

Warning: include(./forums/common.php) [function.include]: failed to open stream: No such file or directory in /home/josh/www/forums/news.php on line 50

Warning: include() [function.include]: Failed opening './forums/common.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/josh/www/forums/news.php on line 50

Warning: include(./forums/includes/functions_display.php) [function.include]: failed to open stream: No such file or directory in /home/josh/www/forums/news.php on line 51

Warning: include() [function.include]: Failed opening './forums/includes/functions_display.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/josh/www/forums/news.php on line 51

Warning: include(./forums/includes/bbcode.php) [function.include]: failed to open stream: No such file or directory in /home/josh/www/forums/news.php on line 52

Warning: include() [function.include]: Failed opening './forums/includes/bbcode.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/josh/www/forums/news.php on line 52

Fatal error: Call to a member function session_begin() on a non-object in /home/josh/www/forums/news.php on line 55
My news.php code:

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', 5);                    // Forum ID to get data from

define('POST_LIMIT', 7);                  // How many to get

define('PHPBB_ROOT_PATH', './forums/');   // 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_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<h3>{$m['topic_title']}</h3>";

      echo "\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>";

      echo "\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);

}



?>
TheRazer
Registered User
Posts: 6
Joined: Sat Apr 11, 2009 3:15 am

Re: Front Page News Syndication

Post by TheRazer »

now im stuck :)
im trying to make 2 "news" on same phpbb3 page...
1. news (include news.php)
2. clannwes (include clannews.php)

but i cant get it to work...
i thingk its somthing with 2 define('FORUM_ID',

i want news.php to show
define('FORUM_ID', 2);
and clannews.php to show
define('FORUM_ID', 5);

(same page but difrent tabels)

is there annyone how like to help me?
User avatar
MPG187
Registered User
Posts: 519
Joined: Sun Apr 12, 2009 7:39 pm
Location: Operation420.net
Name: Operation 420
Contact:

Re: Front Page News Syndication

Post by MPG187 »

I have an other administrator of the site who wants to install this.

What would happen if I am on the forum while he is installing this? Will the forum be down or something while he installs it or will there be no effect?
phpBB 3.0.4, http://operation420.net/forum, download package from phpBB.com (fresh install), mods installed, British English, MySQL 4.1.14
SoleAngelus
Registered User
Posts: 1
Joined: Tue Apr 14, 2009 3:47 am

Re: Front Page News Syndication

Post by SoleAngelus »

Hi, love this mod jus need some help.

I want to be able to output the list of forum posts/topics to a different html file.

So on the index.html there would be a list of new posts, can anyone help me?

Regards,

SoleAngelus
Locked

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