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
Kamano
Registered User
Posts: 9
Joined: Thu Feb 19, 2009 12:41 am

Re: Front Page News Syndication

Post by Kamano »

Hmm, that's almost what I was looking for (the line change option), but now the info is to the right of/below the actual post body.

How might I make sure it's still between the title and the body of the post?


I've got this all in an iframe on my main page, so it brings the right aligned text much closer to the center of the screen in general, but I'd still like it right-aligned so that it looks proper within the frame, if that makes sense.
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:Hmm, that's almost what I was looking for (the line change option), but now the info is to the right of/below the actual post body.

How might I make sure it's still between the title and the body of the post?


I've got this all in an iframe on my main page, so it brings the right aligned text much closer to the center of the screen in general, but I'd still like it right-aligned so that it looks proper within the frame, if that makes sense.
Try this.

Add to the top of news.php (before the <?php tag):

Code: Select all

<div style="margin: 0 auto; width: 600px;">
Changing 600px to whatever the width of your iframe is.

Then the following at the end of the page (after the ?>):

Code: Select all

</div>

Finally change the line I mentioned before to:

Code: Select all

      echo "\n<h4 class=\"postinfo\" style=\"text-align: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>";  
See if that does the trick.
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 »

chAos wrote:
w00t! wrote:Bump!
daGrevis wrote:I use SEO MOD, how can i get this work?
I'm not familiar with that mod, sorry.
Maybe you can take look at that MOD? http://www.phpbb-seo.com/ ! I think, that you should change some thinks, like "t.topic_title" to get work it... Can you help me?
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! »

chAos wrote:
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.
Works perfect. Thanx a lot! :D
barsa
Registered User
Posts: 34
Joined: Mon Sep 02, 2002 10:16 pm

Re: Front Page News Syndication

Post by barsa »

barsa wrote:
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. :)
Anyone please?
Kamikazi
haywarc
Registered User
Posts: 10
Joined: Sun Feb 15, 2009 5:50 am
Contact:

Re: Front Page News Syndication

Post by haywarc »

@barsa
Sorry I have been heaps busy at work and haven't had a chance to look at this, but I have created the same type of thing for my forum.
Example at: http://www.madcowlab.com/index.php

I am using NV recent topics 1.0.3 for the Right Hand Stack and this syndication for the main story and articles.

I have changed my index.php file to forums.php and created a new index.php for a "Portal Page". I have also installed [Beta] View single post 0.1.0 to create an article style page.

Let me know what you think barsa. There are some code changes that need to be made to php files and html templates in order to get it up and running. How good are you with php?
User avatar
JamesA
Registered User
Posts: 28
Joined: Wed Oct 26, 2005 7:46 pm
Contact:

Re: Front Page News Syndication

Post by JamesA »

chAos wrote:
rphMedia wrote:This is great, I tried using it as an "include" on my home page, but everyone's getting a "headers already sent" error (I don't get the errors, which is the weird part) and they're session dumps out of the forum?? So, they're having to log back in to the forum even though they have the "remember me" set. Is there something I'm missing? I really like the feature.

The first part of the script (where it's including the phpBB files) has to be done before you print any HTML to the page. So if you're integrating it with an existing PHP page, you should put everything upto and including line 59 at the very top, and then the rest of it where you actually want the news to appear.
Hi chAos,
I have the same problem as described by rphMedia but I dont understand the fix or cant get it to work. My page looks fine in FireFox but shows the errors in Internet Explorer and Google Chrome. Can you explain your answer differently for me. I must be a bit slow on the uptake :oops: The page I'm trying it on is here.
barsa
Registered User
Posts: 34
Joined: Mon Sep 02, 2002 10:16 pm

Re: Front Page News Syndication

Post by barsa »

I had the same problem but thanks to everyone who helped, especially haywarc!

I'll post all my files here but please mind that my setup is per the following:

- My forum is a subdirectory (example: /home/user/public_html/forum)
- My home.php file is actually my index.php (located: /home/user/public_html/index.php)
- My news.php is located in the same directory as index.php.
- My home_body.html located in template directory (example: /home/user/public_html/forum/styles/prosilver/template/home_body.html)

This is my index.php

Code: Select all

<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();

    page_header('Home');

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

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();
?>
This is my 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', 30);                    // Forum ID to get data from
    define('POST_LIMIT', 7);                  // How many to get
    define('PHPBB_ROOT_PATH', './forum/');   // 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;

    // 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=".FO
RUM_ID."&t={$m['topic_id']}\">{$m['topic_replies']} {$comment}</a> // {$m['username']}</h4>";


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

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

?>
This is my home_body.html

Code: Select all

<!-- INCLUDE overall_header.html -->


<div id="site_content" style="width:70%;float:right;">    
    <div class="panel">
       <div class="inner">
          <span class="corners-top"><span></span></span>
<style type="text/css">

p
{
font-size: 15px;
max-width: 300px;
margin-left: 10px;
}
</style>

<p>
<!-- PHP --> include("news.php"); <!-- ENDPHP -->
</p>
<br>
 <span class="corners-bottom"><span></span></span>
</div>
</div>
</div>

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

<!-- INCLUDE overall_footer.html -->
I hope that helps anyone trying to fix their double-header error, maybe it can cut the agony on others just starting. :)
Kamikazi
slxception
Registered User
Posts: 3
Joined: Mon Oct 01, 2007 3:03 pm

Re: Front Page News Syndication

Post by slxception »

I noticed a serious flaw with this mod, and I'm hoping this can be addressed:

The file says it starts a session as a Guest user. But the forum I have used to pull the topics from requires login to see. (Mind you, I'm just testing right now.) Even when I'm logged out, it will show posts from this forum. If it can pull settings as if a guest, but show protected forums, that's like circumventing security rules, and can be a serious issue. Is this behavior intentional?
weedgur79
Registered User
Posts: 349
Joined: Mon Dec 22, 2008 3:58 am
Contact:

Re: Front Page News Syndication

Post by weedgur79 »

Would it be possible to integrate this feature within a flash created front end page of a website with connected phpbb3 forum*
Dioxid
Registered User
Posts: 2
Joined: Sun Mar 01, 2009 8:18 pm

Re: Front Page News Syndication

Post by Dioxid »

chAos wrote:
whiskey_peat wrote:Any thoughts on trimming the topic titles :roll:
Check out the first function on this page to use to shorten strings (coincidence on the timing since I was just reading that page earlier :P). Put that block at the top of the script below the <?php tag. Then, on line 115 add the following code:

Code: Select all

$m['topic_title'] = truncate($m['topic_title'], 00);      
Where 00 is the number of characters to shorten it to.
And if anyone wants to shorten the post itself, just change the two 'topic_title' to 'post_text'. For example:

Code: Select all

$m['post_text'] = truncate($m['post_text'], 40);   
Mathijs1988
Registered User
Posts: 112
Joined: Wed Aug 08, 2007 9:54 am

Re: Front Page News Syndication

Post by Mathijs1988 »

I have no idea where to start. Is there anyone that can explain how to start off with this?
Dioxid
Registered User
Posts: 2
Joined: Sun Mar 01, 2009 8:18 pm

Re: Front Page News Syndication

Post by Dioxid »

I am trying to edit the comments link (that link to the news). I want it to open up in a new custom specified window. I got it working by using this window.open script. But my problem is that it loads the in the main browser window too, not only in the new window. :| Can it be that it does not return false? I've tried to fix that if that is the problem but without success.

Here is what I have added in the php:

Code: Select all

<script type="text/javascript">
<!--
function customwindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
And in the href with the onclick function:

Code: Select all

<a href="".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$m['topic_id']}\"onclick=customwindow(this.href,'','width=750,height=500,scrollbars=1,resizable=1');return false\">{$m['topic_replies']} {$comment}</a>
Any help is much appreciated! ;)
haywarc
Registered User
Posts: 10
Joined: Sun Feb 15, 2009 5:50 am
Contact:

Re: Front Page News Syndication

Post by haywarc »

Dioxid wrote:I am trying to edit the comments link (that link to the news). I want it to open up in a new custom specified window. I got it working by using this window.open script. But my problem is that it loads the in the main browser window too, not only in the new window. :| Can it be that it does not return false? I've tried to fix that if that is the problem but without success.
Hi Dioxid, I would try the below. Just replace the href value with # and use the onClick to generate the page.

A very basic example

Code: Select all

onClick="window.open('URL To Open','mywindow','width=400,height=200')"
ge_rpger
Registered User
Posts: 81
Joined: Sat Jul 24, 2004 2:20 pm

Re: Front Page News Syndication

Post by ge_rpger »

I followed the edit in basra's latest post http://www.phpbb.com/community/posting. ... #pr8755605 but I'm getting the following error.

Code: Select all

Fatal error: Class 'bbcode' not found in /public_html/phpBB3/news.php on line 94
And line 94 or there about is the following code

Code: Select all

        // Instantiate BBCode
        if ($bbcode_bitfield !== '')
        {
           $bbcode = new bbcode(base64_encode($bbcode_bitfield));
        }
I'm trying to place this "news" on my home.php page and that's the error I'm getting.
Locked

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