BETA Custom News Block

Forum rules
This forum is not for support requests.

Only post Modifications for Board3 Portal 1.0.x in this forum.

Topic author
hooplah
Active Member
Posts: 22
Joined: 16. September 2008 14:26

BETA Custom News Block

Post by hooplah »

I have been working on a custom news block that displays a compact recent news item of any singular forums. I have it so far that it takes you to the forum of a last post but not to the last post in that forum. So the link generated would be something like; http://web site/viewtopic.php?f2&t=26

EDIT: Code working fine after changing as was advised :D

here is the code if it needs improving let me know ;)

latest_posts.php

Code: Select all

<?php

/**
*
* @package - Board3portal
* @version $Id: latest_members.php 325 2008-08-17 18:59:40Z kevin74 $
* @copyright (c) kevin / saint ( www.board3.de/ ), (c) Ice, (c) nickvergessen ( www.flying-bits.org/ ), (c) redbull254 ( www.digitalfotografie-foren.de ), (c) Christian_N ( www.phpbb-projekt.de )
* @based on: phpBB3 Portal by Sevdin Filiz, www.phpbb3portal.com
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

$offsets = 10;
$forumnumber = 2;

$sqls  = "SELECT * FROM phpbb_posts WHERE forum_id = '$forumnumber' ORDER BY Post_id DESC LIMIT $offsets";

$results = $db->sql_query($sqls);

// print the results in a table

while($list = $db->sql_fetchrow($results))
  {

    $template->assign_block_vars('reviews_rows', array(
    
'U_NEWNEWSLINK'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $list['forum_id'] . '&t=' . $list['topic_id'] . '&p=' . $list['post_id'] . '#p' . $list['post_id']), 
'R_RELEASETITLE'          => $list['post_subject']

        )
    );
  }


$template->assign_vars(array(
    'S_DISPLAY_LATEST_POSTS' => true,
));

?>
latest_posts.html

Code: Select all

<table class="tablebg" cellspacing="1" width="100%">
    <tr>
        <th class="cat"><span style="float: left"><img src="{T_THEME_PATH}/images/portal/portal_members.png" width="16px" height="16px" alt="" />&nbsp;Latest Additions</span></th>
    </tr>
    <tr class="row1">
        <td>
            <span style="float:left;"><strong>{Title}</strong></span>
            
            <!-- BEGIN reviews_rows -->

            <a href="{reviews_rows.U_NEWNEWSLINK}" >{reviews_rows.R_RELEASETITLE}</a>
         
            <br style="clear:both" />
            
            <!-- END reviews_rows -->
        </td>
    </tr>
</table>
<br /> 
If anyone wants to try this create and put the latest_posts.php in the root\portal\blocks folder, then create latest_posts.html in root\styles\your style\templates\portal\blocks folder.
edit root\portal.php find

Code: Select all

    if ($portal_config['portal_welcome'])
    {
        include($phpbb_root_path . 'portal/block/welcome.'.$phpEx);
    } 
add after

Code: Select all

        include($phpbb_root_path . 'portal/block/latest_posts.'.$phpEx);     
edit root\styles\your style\template\portal\portal_body.php and add the following line where you want the block to appear

Code: Select all

            <!-- INCLUDE portal/block/latest_posts.html --> 
to set the forum you want to display change the value in latest_posts.php for $forumnumber
Last edited by hooplah on 1. November 2008 18:21, edited 1 time in total.

Topic author
hooplah
Active Member
Posts: 22
Joined: 16. September 2008 14:26

Re: BETA Custom News Block

Post by hooplah »

Ok I know i need to use append_sid() function in includes\functions to set sid.

should it be something like

'U_NEWNEWSLINK' => append_sid("{$phpbb_root_path}viewtopic.$phpEx"),

or should i use something like this in the page?

append_sid("{$phpbb_root_path}viewtopic.$phpEx?t=1&f=2");


Any help would be greatly appreciated. Thanks ;)
User avatar

Kevin
Site Admin
Posts: 2989
Joined: 7. January 2006 20:11
phpBB.de User: Saint
phpBB.com User: Saint_hh
Location: Hamburg
Contact:

Re: BETA Custom News Block

Post by Kevin »

Hi,

i would suggest to do it this way:

replace:

Code: Select all

      'R_ID'                      => $list['post_id'],
      'R_TOPICID'                  => $list['topic_id'],
      'R_FORUMID'                  => $list['forum_id'], 
with:

Code: Select all

'U_NEWNEWSLINK'   => append_sid("$phpbb_root_path}viewtopic.$phpEx", 'f=' . $list['forum_id'] . '&t=' . $list['topic_id'] . '&p=' . $list['post_id'] . '#p' . $list['post_id']), 
and in your template instead of:

Code: Select all

<a href="./viewtopic.php?f{reviews_rows.R_FORUMID}&t={reviews_rows.R_TOPICID}" >{reviews_rows.R_RELEASETITLE}</a> 
just:

Code: Select all

<a href="{reviews_rows.U_NEWNEWSLINK}" >{reviews_rows.R_RELEASETITLE}</a> 
Thank you for sharing! :D
~~~ They say the definition of madness is doing the same thing and expecting a different result ~~~

Kein Support per PN / No support via PM!

Topic author
hooplah
Active Member
Posts: 22
Joined: 16. September 2008 14:26

Re: BETA Custom News Block

Post by hooplah »

Thanks for the help Kevin got it working a treat.

had to change

Code: Select all

'U_NEWNEWSLINK'   => append_sid("$phpbb_root_path}viewtopic.$phpEx", 'f=' . $list['forum_id'] . '&t=' . $list['topic_id'] . '&p=' . $list['post_id'] . '#p' . $list['post_id']), 
to this

Code: Select all

'U_NEWNEWSLINK'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $list['forum_id'] . '&t=' . $list['topic_id'] . '&p=' . $list['post_id'] . '#p' . $list['post_id']), 
Updated the code in my orriginal files so anyone who would like this block can have it working fine.

:D

Superman
Active Member
Posts: 4
Joined: 24. October 2008 17:36

Re: BETA Custom News Block

Post by Superman »

I've tried adding this block twice and I keep getting errors and lines of code saying it can't modify the header. It also breaks the CSS and the text on the page looks huge.

Topic author
hooplah
Active Member
Posts: 22
Joined: 16. September 2008 14:26

Re: BETA Custom News Block

Post by hooplah »

can you post a board link m8 so i can see?

the.ronin
Valued Contributor
Posts: 64
Joined: 30. October 2008 16:20

Re: BETA Custom News Block

Post by the.ronin »

Great mod! Thanks for sharing.

Any suggestions on how to exclude stickied posts or announcements? Also to limit the number of characters in the title?

[edit] I also notice it is posting responses. Any way to get rid of that too?

freedose
Active Member
Posts: 3
Joined: 29. December 2008 13:26
phpBB.de User: freedose
phpBB.com User: freedose

Re: BETA Custom News Block

Post by freedose »

Hi,
this is great mod... but i got eror:

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3548: Cannot modify header information - headers already sent by (output started at /portal/block/latest_posts.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3550: Cannot modify header information - headers already sent by (output started at /portal/block/latest_posts.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3551: Cannot modify header information - headers already sent by (output started at /portal/block/latest_posts.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3552: Cannot modify header information - headers already sent by (output started at /portal/block/latest_posts.php:1)
what im wrong? Im follow what exactly your code.

Topic author
hooplah
Active Member
Posts: 22
Joined: 16. September 2008 14:26

Re: BETA Custom News Block

Post by hooplah »

freedose wrote:Hi,
this is great mod... but i got eror:

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3548: Cannot modify header information - headers already sent by (output started at /portal/block/latest_posts.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3550: Cannot modify header information - headers already sent by (output started at /portal/block/latest_posts.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3551: Cannot modify header information - headers already sent by (output started at /portal/block/latest_posts.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3552: Cannot modify header information - headers already sent by (output started at /portal/block/latest_posts.php:1)
what im wrong? Im follow what exactly your code.
make sure there is no spaces before the <?php line on line 1

freedose
Active Member
Posts: 3
Joined: 29. December 2008 13:26
phpBB.de User: freedose
phpBB.com User: freedose

Re: BETA Custom News Block

Post by freedose »

thanks bro!
it work now....

it show like this.
Image


if you could tell me, if able to make table like image below:
Image

Topic author
hooplah
Active Member
Posts: 22
Joined: 16. September 2008 14:26

Re: BETA Custom News Block

Post by hooplah »

No Problems, keep an eye on this post over the next couple of weeks i'll make some variations ;)

freedose
Active Member
Posts: 3
Joined: 29. December 2008 13:26
phpBB.de User: freedose
phpBB.com User: freedose

Re: BETA Custom News Block

Post by freedose »

of coz bro!
always in my notify topic....

Matt
Active Member
Posts: 1
Joined: 7. February 2009 07:09

Re: BETA Custom News Block

Post by Matt »

First, I love this mod. Thank you very much for making it available. I have a quick question about adapting it. Is there a way to make just this block display only the newest topic, without showing replies and without having newly replied to topics show back up?

Thank you very much for your time,
Matt

can99
Active Member
Posts: 2
Joined: 6. March 2009 01:41

CHANGE NEEDED

Post by can99 »

TO make this mod work with the latest version of the Database I had to change this line in latest_post.php



$sqls = "SELECT * FROM phpbb_posts WHERE forum_id = '$forumnumber' ORDER BY Post_id DESC LIMIT $offsets";

to


$sqls = "SELECT * FROM posts WHERE forum_id = '$forumnumber' ORDER BY Post_id DESC LIMIT $offsets";

can99
Active Member
Posts: 2
Joined: 6. March 2009 01:41

How would you add 2 of these blocks to portal.php?

Post by can99 »

Does anyone have any idea how you could add 2 of these mods to the portal page WITHOUT is screwing up the posts, see I added 2 versions of the mod, one called latest_posts.html and .php and another called latest_newpost.html and .php, and added the code to the portal.php and portal_body.html

It works BUT it just simply duplicates the forum posts in each block ... ie:

Local Business
Concession Trailer For Your Next Event
artist needs condo>guest house

New Poster Lounge
Concession Trailer For Your Next Event
artist needs condo>guest house

Now I am missing something really really simple, does anyone know what it is?
Locked

Return to “board3 Portal v1.0.x - Modifications in Dev”