
hi
(NOTE : ONLY FOR those who make another simple news MOD)
http://www.4homepages.de/forum/index.php?topic=9064.0i do make a poor mod for 4images users so they can make rss feed for ther news section
NO need to change any files
1st file is newsrssfeed.php which change the cod from php to rss lang
2nd file is read-rss-library-news.php to change the rss into html or php lang again
the 3rd file is the templates file rss.html
now
newsrssfeed.php<?
/*************************************************
* RSS Feed for 4images *
* beta 0.1 *
* Email:
*/
//------------ CONFIG ----------------------------
$num_new_images = 10;
//because we have no session here, we have to hardcode this values
define('SCRIPT_URL', 'http://www.your-website.com/4images'); //no trailing slash
define('LANGUAGE', 'english');
define('ROOT_PATH', './');
//----- END CONFIG--------------------------------------------
include(ROOT_PATH.'global.php');
$main_template = 'rss';
$sql = "SELECT news_id, news_title, news_text, user_name, news_date
FROM ".NEWS_TABLE."
ORDER BY news_id DESC
LIMIT $num_new_images";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
$format="Y-m-d\TH:i:s+00:00"; //the time format for rss date
while($news_row = $site_db->fetch_array($result)){
$site_template->register_vars(array(
"title" => $news_row["news_title"],
"description" => $news_row["news_text"],
"link" => SCRIPT_URL."/newsfull.php?news_id=".$news_row["news_id"],
"id" => SCRIPT_URL."/newsfull.php?news_id=".$news_row["news_id"],
"date" => format_date($format,$news_row["news_date"]),
));
$new_images.=$site_template->parse_template("rssitem");
}
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(
array(
"ctitle" => $config['site_name'],
"clink" => SCRIPT_URL,
"cdescription" => $config['site_name']." RSS Feed",
"language" =>LANGUAGE,
"ititle" =>"",
"iurl" => SCRIPT_URL."/".TEMPLATE_PATH."/images/header_logo.gif",
"ilink" => SCRIPT_URL,
"items" => $new_images,
)
);
header("Content-type: text/xml");
$site_template->print_template($site_template->parse_template($main_template));
?>now the read-rss-library-news.php<?php
// Basic Requirements
$backend = "http://www.your-website.com/4images/newsrssfeed.php";
// End
// variables needed later
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
// end
function startElement($parser, $tagName, $attrs) {
// The function used when an element is encountered
global $insideitem, $tag;
if ($insideitem) {
$tag = $tagName;
} elseif ($tagName == "ITEM") {
$insideitem = true;
}
}
function characterData($parser, $data) {
// The function used to parse all other data than tags
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
$aboreem = str_replace ($nums, $images, $link);
$link = $aboreem;
break;
}
}
}
function endElement($parser, $tagName) {
// This function is used when an end-tag is encountered.
global $insideitem, $tag, $title, $description, $image, $link;
if ($tagName == "ITEM") {
printf("<p><b><a href='%s'><li>%s</li></a></b></p>", // make our title into an actual link
trim($link),htmlspecialchars(trim($title))); // remove html characters from the title
printf("<p><b>%s</b></p>",$description); // Print out the live journal entry
$title = $description = $link = $insideitem = false;
}
}
// Now to the parsing itself. Starts by creating it:
$xml_parser = xml_parser_create();
// Then setup the handlers:
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
// Open the actual datafile:
$fp = fopen($backend, r);
// Run through it line by line and parse:
while ($data = fread($fp, 4096)) {
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
// Close the datafile
fclose($fp);
// Free any memmory used
xml_parser_free($xml_parser);
?>and for the rss.html <?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>{ctitle}</title>
<link>{clink}</link>
<description>{cdescription}</description>
<language>{language}</language>
<image>
<title>{ititle}</title>
<url>{iurl}</url>
<link>{ilink}</link>
</image>
{items}
</channel>
</rss>thats all
sorry for my poor english