PDA

View Full Version : RSS feed >(


Finalmen
01-04-2007, 05:49 PM
Hello,

i really would like some help with my RSS feed what i want to do is make a module,an in that i want to show the new's.





<?php
$_item = array();
$_depth = array();
$_tags = array("dummy");





function initArray()
{
global $_item;

$_item = array ("TITLE"=>"", "LINK"=>"",
"DESCRIPTION"=>"", "URL"=>"");
}

function startElement($parser, $name){
global $_depth, $_tags, $_item;

if (($name=="ITEM") ||
($name=="CHANNEL")
|| ($name=="IMAGE")) {
initArray();
}
@$_depth[$parser]++;
array_push($_tags, $name);
}

function endElement($parser, $name){
global $_depth, $_tags, $_item;

array_pop($_tags);
$_depth[$parser]--;
switch ($name) {
case "ITEM":
echo "<a href=\"http://www.worldofwar.net\">" .
"{$_item['TITLE']}</a><br>";
initArray();
break;



}
}

function parseData($parser, $text){
global $_depth, $_tags, $_item;

$crap = preg_replace ("/\s/", "", $text);
/* is the data just whitespace?
if so, we don't want it! */

if ($crap) {
$text = preg_replace ("/^\s+/", "", $text);
/* get rid of leading whitespace */
if (@$_item[$_tags[$_depth[$parser]]]) {
$_item[$_tags[$_depth[$parser]]] .=
$text;
} else {
$_item[$_tags[$_depth[$parser]]] =
$text;
}
}
}

function parseRDF($file){
global $_depth, $_tags, $_item;

$xml_parser = xml_parser_create();
initArray();

/* Set up event handlers */
xml_set_element_handler
($xml_parser, "startElement", "endElement");
xml_set_character_data_handler
($xml_parser, "parseData");

/* Open up the file */
$fp = fopen ($file, "r") or die ("Could not
open $file for input");

while ($data = fread ($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof
($fp))) {
die (sprintf("",
xml_error_string(xml_get_error_code
($xml_parser)),
xml_get_current_line_number
($xml_parser)));
}
}

fclose($fp);
xml_parser_free($xml_parser);
}

parseRDF
("http://forums.worldofwar.net/external.php?type=rss1&forumids=126");
?>


should be news code i had to add on the page but i dont know where to put it?


Thanks alot for your help iam stil kinda new to this


Finalmen

Brian
01-05-2007, 12:43 PM
Create a new file called rss.php (or whatever, just using rss.php as an example) with the content above. Upload that to your forum/modules directory. Then login to your Admin CP, click on Add Module, click "PHP File Module", and then fill in the blanks. Be sure to select rss.php as the file to include, and you'll probably need to turn the "Clean File Output" option on as well.

Our Sponsors
 

Finalmen
01-07-2007, 01:44 PM
hey thanks for saying that it worked :D or atleast kinda now it sais the title of the news like


bla bla
blbla bla bla
bla bla bla bla
bla bla bla bla
[bar]

the bars that are normally above the post/module is now under it what did i do wrong? should i add somthing to the code? thanks.

Brian
01-08-2007, 01:38 PM
Did you turn the "Clean File Output" option on for that module?