Topic: Formatting extern.php to display news items with content
Here's a modification for extern.php to have a more complicated HTML display. It's used here as a news feed:
http://www.audiogames.net/index.php
Copy extern.php to a new file (e.g. extern_new.php).
Replace the function output_html with the following code:
#############################################################################
#############################################################################
###############################CREATIVEHERO.ES###############################
#############################################################################
#############################################################################
function output_html($feed)
{
$length_of_content=500;
// Send the Content-type header in case the web server is setup to send something else
header('Content-type: text/html; charset=utf-8');
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
foreach ($feed['items'] as $item)
{
if (utf8_strlen($item['title']) > 80)
$subject_truncated = forum_htmlencode(forum_trim(utf8_substr($item['title'], 0, (FORUM_EXTERN_MAX_SUBJECT_LENGTH - 5)))).'…';
else
$subject_truncated = forum_htmlencode($item['title']);
//Truncate post contents
if (utf8_strlen( $item['description']) > $length_of_content)
$content_truncated = forum_trim(utf8_substr($item['description'], 0, ($length_of_content - 3)))."...";
else
$content_truncated = $item['description'];
$content_truncated=strip_tags($content_truncated);
//adapt style headings here
echo '<h3>'.$subject_truncated.'</h3>';
echo "<p>".$content_truncated;
echo ' [<a href="'.$item['link'].'" title="'.forum_htmlencode($item['title']).'">read more</a>]</p>';
echo "<p class='newssmall'>".gmdate('F d, Y ', $item['pubdate'])."</p>";
}
}
#############################################################################
#############################################################################
#############################################################################
#############################################################################
#############################################################################
Call from your php page is for instance:
<?
$a = file_get_contents("http://forum.yourdomain.com/extern_new.php?action=feed&type=html&show=4&fid=20");
echo $a;
?>
Where 4 is the number of displayed posts and 20 the ID of the news forum room.
Include this class in your main CSS style:
p.newssmall
{
font-size: 60%;
}
This way, you can use a forum room of your PunBB as a news post system.
Best,
Sendermen