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.
azzam
Registered User
Posts: 345
Joined: Sat May 03, 2008 11:33 am

Re: Front Page News Syndication

Post by azzam »

Thanks for mod..Looking for a news from a long time.

Some ques?

Any way so it could be integrated with prosilver style?
And a post with few characters and read more link to view the post?
A category wise news list ?

Thank you
Azzam Malik
I love mods :)
barsa
Registered User
Posts: 34
Joined: Mon Sep 02, 2002 10:16 pm

Re: Front Page News Syndication

Post by barsa »

haywarc wrote:P

There where a few things to remove from news.php as they where being sent twice.

Example Screenshot
Image
I'm kinda stuck at this stage, could you please post the whole code or at least point out what things to removed from the code?

Many thanks
Kamikazi
User avatar
zourbuth
Translator
Posts: 89
Joined: Sun Jan 11, 2009 5:39 am
Location: Indonesia
Name: Sastra Manurung
Contact:

Re: Front Page News Syndication

Post by zourbuth »

I got this when pulling the post which are using BBCode,
It is OK if the post text only

Code: Select all

Fatal error: Class 'bbcode' not found in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpBB\tips.php on line 42
Anyone can describe this?
Download Bahasa Indonesia Language Pack
haywarc
Registered User
Posts: 10
Joined: Sun Feb 15, 2009 5:50 am
Contact:

Re: Front Page News Syndication

Post by haywarc »

@barsa

Are you getting PHP errors on the page now? or just nothing?

Here are the changes that I have made to news.php. This can be done other ways, this is just the way that I chose. I give full credit to chAos for creating this syndication.

My home.php and news.php are in my root directory and the home_body.html is in my theme > Templates directory.

Removed the below code as it was already being sent by home.php

Code: Select all

include($phpbb_root_path . 'common.' . $phpEx);


Removed the below code as it was already being sent by home.php

Code: Select all

$auth->acl($user->data);
under $user->session_begin(false); on line 55 (roughly), I added

Code: Select all

global $db;
here is the code from my news.php file

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', './');   // 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']);



?>
barsa
Registered User
Posts: 34
Joined: Mon Sep 02, 2002 10:16 pm

Re: Front Page News Syndication

Post by barsa »

Thanks a lot haywarc, all working now. Any idea how to limit the width of the whole parsed post to 300pixel or something? having done that, anyway to add some colums to the right (like Recent announcements, latest topics, etc)?

thanks in advance
Kamikazi
User avatar
w00t!
Registered User
Posts: 179
Joined: Thu Feb 12, 2009 12:33 am
Location: Santiago, Chile

Re: Front Page News Syndication

Post by w00t! »

Hey guys, I managed to customize it and looks fab on my site! But I have a problem:

I have 2 versions of my site, one in english and the other one in japanese. The english one works 100%, but in the japanese one the characters look weird.

Do I need to add some language function to make the characters display correctly?
User avatar
w00t!
Registered User
Posts: 179
Joined: Thu Feb 12, 2009 12:33 am
Location: Santiago, Chile

Re: Front Page News Syndication

Post by w00t! »

Nevermind, I just had to set the charset as UTF-8!!! It works :mrgreen: Thanx for this awesome mod, you can check my site using it at:

English version http://www.biohaze.com/
Japanese version http://www.biohaze.com/JP/
haywarc
Registered User
Posts: 10
Joined: Sun Feb 15, 2009 5:50 am
Contact:

Re: Front Page News Syndication

Post by haywarc »

@barsa

All you need to do is change the home_body.html file. A HTML change should get you the result you need.
barsa
Registered User
Posts: 34
Joined: Mon Sep 02, 2002 10:16 pm

Re: Front Page News Syndication

Post by barsa »

haywarc wrote:@barsa

All you need to do is change the home_body.html file. A HTML change should get you the result you need.
Thanks again Haywarc, well this is my home_body.html

Code: Select all

    <!-- INCLUDE overall_header.html -->

    <div id="site_content" style="width:70%;float:left;">   
    <style type="text/css">
    p
    {
    max-width: 300px
    }
    p.leftmargin {margin-left: 10px}


    h3
    {
    margin-left: 10px
    }

    h2
    {
    margin-left: 10px
    }

    </style>

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

    </div>

        <div id="sidebar" style="width:28%;float:right;">

        <!-- IF not S_USER_LOGGED_IN -->
           <div class="panel">
           <div class="inner"><span class="corners-top"><span></span></span>
           <h3>Forum Login</h3>
           <form method="post" action="{ROOT_PATH}ucp.php?mode=login">
           <fieldset>
              <dl>
                 <dt><label for="username">Username:</label></dt>
                 <dd><input type="text" class="inputbox autowidth" name="username" id="username" value="" size="15" /></dd>
              </dl>
              <dl>
                 <dt><label for="password">Password:</label></dt>
                 <dd><input type="password" class="inputbox autowidth" name="password" id="password" value="" size="15" /></dd>
              </dl>
              <input class="button1" name="login" type="submit" value="Login" accesskey="s" />
           </fieldset>
           </form>
           <span class="corners-bottom"><span></span></span></div>
           </div>
        <!-- ENDIF -->

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

           <!-- BEGIN announcement_row -->
           <div style="margin-bottom: 4px;">
           <strong><a href="{announcement_row.U_ANNOUNCEMENT}">{announcement_row.TITLE}</a></strong><br />
           Posted by {announcement_row.POSTER_FULL} on {announcement_row.TIME}
           </div>
           <!-- END announcement_row -->

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

        </div>

        <br style="clear: both;" />

    <!-- INCLUDE overall_footer.html -->
The announcements function comes from a functions file called website_functions.php in /includes directory:

Code: Select all

<?php

    /**
    * (c) 2008 Highwaymen, http://the-webmasters-resource.info
    **/


    /**
    *
    *@ SETTINGS / CUSTOMIZING
    *@
    *@ $forum_id = 2
    *@ Change the 2 variable to which FORUM ID you want the annoucnements to be pulled from.
    *@ $number_to_show = 8
    *@ Change the 8 variable to how ever many announcements you want displayed.
    *
    */
    function phpbb_fetch_home_announcements($forum_id = 2, $number_to_show = 8)
    {
        global $db, $user, $template;
        global $phpbb_root_path, $phpEx;

        //$forum_id = 2;
        //$number_to_show = 8;

        $sql = 'SELECT
            t.forum_id,
            t.topic_id,
            t.topic_last_post_id,
            t.topic_time,
            t.topic_title,
            t.topic_poster,
            u.username,
            u.user_id,
            u.user_type,
            u.user_colour
        FROM
            ' . TOPICS_TABLE . ' AS t,
            ' . USERS_TABLE . ' AS u
        WHERE
            t.forum_id = ' . $forum_id . ' AND
            t.topic_poster = u.user_id
        ORDER BY
            t.topic_time DESC';
        $result = $db->sql_query_limit($sql, $number_to_show);

        while ($row = $db->sql_fetchrow($result))
        {
            $template->assign_block_vars('announcement_row', array(
                'TITLE'                    => $row['topic_title'],
                'U_ANNOUNCEMENT'     => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row$
                'TIME'                         => $user->format_date($row['topic_time']),
                'POSTER_FULL'            => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
            ));
        }
        $db->sql_freeresult($result);
    }

?>
How do i add this function and add a side bar of Recent announcements or latest posts/top posters, etc.

as usual, thanks in advance. :)
Kamikazi
User avatar
w00t!
Registered User
Posts: 179
Joined: Thu Feb 12, 2009 12:33 am
Location: Santiago, Chile

Re: Front Page News Syndication

Post by w00t! »

Hey again, I got a question: can I exclude a certain topic ID from being displayed? I'd like to display all the topics from a forum, except one. Maybe using the define funcstion?
Last edited by w00t! on Wed Feb 18, 2009 6:16 pm, edited 1 time in total.
User avatar
w00t!
Registered User
Posts: 179
Joined: Thu Feb 12, 2009 12:33 am
Location: Santiago, Chile

Re: Front Page News Syndication

Post by w00t! »

Bump!
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 »

I use SEO MOD, how can i get this work?
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 »

w00t! wrote:Bump!
A very crude way that should work is to below...

Code: Select all

foreach($posts as $m)
{ 
Add

Code: Select all

    if( $m['topic_id'] == xx )
    {
        continue;
    } 
Where xx is the ID of the topic you want to exclude. I think that should work though I can't test its behaviour right now.
daGrevis wrote:I use SEO MOD, how can i get this work?
I'm not familiar with that mod, sorry.
Kamano
Registered User
Posts: 9
Joined: Thu Feb 19, 2009 12:41 am

Re: Front Page News Syndication

Post by Kamano »

I feel unbelievably silly for having such a hard time with this, but I can't seem to find a working answer, so, here goes.

How would I go about right-aligning text that is output with this?

I'm attempting to right-align the "<date & time> by <user> with <comments>" line, but for whatever reason, I can't seem to do it without it throwing an error from that line. I'm able to easily center-align all pieces of the output, including this one. But right-aligning it is giving me headaches. If someone could demonstrate the proper way to right-align that particular piece of the script, I'd be very grateful.
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 »

Kamano wrote:I feel unbelievably silly for having such a hard time with this, but I can't seem to find a working answer, so, here goes.

How would I go about right-aligning text that is output with this?

I'm attempting to right-align the "<date & time> by <user> with <comments>" line, but for whatever reason, I can't seem to do it without it throwing an error from that line. I'm able to easily center-align all pieces of the output, including this one. But right-aligning it is giving me headaches. If someone could demonstrate the proper way to right-align that particular piece of the script, I'd be very grateful.
Hey,

You can either add the following to your CSS file

Code: Select all

.postinfo { float: right; }
or change the line (126)

Code: Select all

      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>"; 
to

Code: Select all

      echo "\n<h4 class=\"postinfo\" style=\"float:right;\">".$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>"; 
Locked

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