Script bewerken voor gebruik met tpl bestand
Geplaatst: 12 apr 2005, 19:31
Ik heb een bestand news.php aangemaakt, maar wil deze ombouwen voor gebruik met een news.tpl bestand. Ik heb echt al van alles geprobeerd, maar ik kan het niet voor elkaar krijgen om de functie $rss_left en $rss_right via news.tpl op te vragen. Mijn bedoeling is om alle echo functies in news.tpl te verwerken en de rss functies op te vragen via news.php...
Het gaat om dit script:
<?php
// standard hack prevent
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
// standard session management
$userdata = session_pagestart($user_ip, PAGE_NEWS);
init_userprefs($userdata);
// set page title
$page_title = 'NEWS';
// standard page header
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
// Start - SCRIPT ========================================================================
function ShowOneRSS($url) {
global $rss;
if ($rs = $rss->get($url)) {
echo "<big><b><a href=\"$rs[link]\">$rs[title]</a></b></big><br />\n";
echo "$rs[description]<br />\n";
echo "<ul>\n";
foreach ($rs['items'] as $item) {
echo "\t<li><a href=\"$item[link]\" title=\"$item[description]\">$item[title]</a></li>\n";
}
if ($rs['items_count'] <= 0) { echo "<li>Sorry, no items found in the RSS file...</li>"; }
echo "</ul>\n";
}
else {
echo "Sorry: It's not possible to reach RSS file $url\n<br />";
// you will probably hide this message in a live version
}
}
// include lastRSS
include "./lastRSS.php";
// List of RSS URLs
$rss_left = array(
'http://freshmeat.net/backend/fm.rdf',
'http://slashdot.org/slashdot.rdf'
);
$rss_right = array(
'http://www.freshfolder.com/rss.php',
'http://phpbuilder.com/rss_feed.php'
);
// Create lastRSS object
$rss = new lastRSS;
// Set cache dir and cache time limit (5 seconds)
// (don't forget to chmod cahce dir to 777 to allow writing)
$rss->cache_dir = './temp';
$rss->cache_time = 1200;
// Show all rss files
echo "<table cellpadding=\"10\" border=\"0\"><tr><td width=\"50%\" valign=\"top\">";
foreach ($rss_left as $url) {
ShowOneRSS($url);
}
echo "</td><td width=\"50%\" valign=\"top\">";
foreach ($rss_right as $url) {
ShowOneRSS($url);
}
echo "</td></tr></table>";
// End - SCRIPT ========================================================================
// assign template
$template->set_filenames(array(
'body' => 'news_body.tpl')
);
$template->pparse('body');
// standard page footer
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
Thank You Verry Much!
Het gaat om dit script:
<?php
// standard hack prevent
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
// standard session management
$userdata = session_pagestart($user_ip, PAGE_NEWS);
init_userprefs($userdata);
// set page title
$page_title = 'NEWS';
// standard page header
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
// Start - SCRIPT ========================================================================
function ShowOneRSS($url) {
global $rss;
if ($rs = $rss->get($url)) {
echo "<big><b><a href=\"$rs[link]\">$rs[title]</a></b></big><br />\n";
echo "$rs[description]<br />\n";
echo "<ul>\n";
foreach ($rs['items'] as $item) {
echo "\t<li><a href=\"$item[link]\" title=\"$item[description]\">$item[title]</a></li>\n";
}
if ($rs['items_count'] <= 0) { echo "<li>Sorry, no items found in the RSS file...</li>"; }
echo "</ul>\n";
}
else {
echo "Sorry: It's not possible to reach RSS file $url\n<br />";
// you will probably hide this message in a live version
}
}
// include lastRSS
include "./lastRSS.php";
// List of RSS URLs
$rss_left = array(
'http://freshmeat.net/backend/fm.rdf',
'http://slashdot.org/slashdot.rdf'
);
$rss_right = array(
'http://www.freshfolder.com/rss.php',
'http://phpbuilder.com/rss_feed.php'
);
// Create lastRSS object
$rss = new lastRSS;
// Set cache dir and cache time limit (5 seconds)
// (don't forget to chmod cahce dir to 777 to allow writing)
$rss->cache_dir = './temp';
$rss->cache_time = 1200;
// Show all rss files
echo "<table cellpadding=\"10\" border=\"0\"><tr><td width=\"50%\" valign=\"top\">";
foreach ($rss_left as $url) {
ShowOneRSS($url);
}
echo "</td><td width=\"50%\" valign=\"top\">";
foreach ($rss_right as $url) {
ShowOneRSS($url);
}
echo "</td></tr></table>";
// End - SCRIPT ========================================================================
// assign template
$template->set_filenames(array(
'body' => 'news_body.tpl')
);
$template->pparse('body');
// standard page footer
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
Thank You Verry Much!
