Script bewerken voor gebruik met tpl bestand

Hulp nodig bij een modificaties of op zoek naar een MOD? Bekijk ons archief. Support wordt helaas niet meer verleend.
Forumregels

Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
phpBB2.0.x
Gesloten
Toverton
Berichten: 5
Lid geworden op: 05 jan 2005, 19:11

Script bewerken voor gebruik met tpl bestand

Bericht door Toverton » 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! :bier:
Laatst gewijzigd door Toverton op 15 apr 2005, 18:07, 1 keer totaal gewijzigd.

Gebruikersavatar
Luuk
Berichten: 7311
Lid geworden op: 22 okt 2003, 10:07
Locatie: Delft

Bericht door Luuk » 12 apr 2005, 22:31

Alle <html> tags kunnen alvast in het .tpl bestand, voor de $php variabele die ertussen zitten, zet ze tussen

Code: Selecteer alles

$template->assign_vars(array(

));
Wordt dan bijvoorbeeld "TEKST" => $tekst,

In het tpl bestand moet je voor die variabele (dus die bij $tekst hoort) dan {TEKST} neerzetten en je bent klaar :bier:
Afbeelding

Gesloten