BETA Custom News Block
Posted: 1. November 2008 15:16
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
here is the code if it needs improving let me know
latest_posts.php
latest_posts.html
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
add after
edit root\styles\your style\template\portal\portal_body.php and add the following line where you want the block to appear
to set the forum you want to display change the value in latest_posts.php for $forumnumber
EDIT: Code working fine after changing as was advised
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,
));
?>
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="" /> 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 />
edit root\portal.php find
Code: Select all
if ($portal_config['portal_welcome'])
{
include($phpbb_root_path . 'portal/block/welcome.'.$phpEx);
}
Code: Select all
include($phpbb_root_path . 'portal/block/latest_posts.'.$phpEx);
Code: Select all
<!-- INCLUDE portal/block/latest_posts.html -->