I know this is probably a dumb nub question but here goes anyway. I want to setup a few rss feeds for display on my site. However, I either need help figuring out hot to put them in an article OR someone tell me how to setup a block with rss type that doesn't get displayed on every part of the site (i.e. I don't want it on the common left, right, or center but on their own pages 1 feed per page lets say).
I setup rss feeds as a test in the block manager and they work great, but I want them in their own little area, not displayed in the common panels. Ideally, I would have menu items in the site map that say News 1, News 2, News 3 as examples, and when I click on News 1, it brings up the feed from a particular source. Same for any others. I'm sure there's probably an easy way to do this but I'm just not seeing it yet.
use this in a PHP article and link to that article in your menu
Place the feed inside the quotes "place your rss feed here inside the quotes"
// An RSS Reader to grab news from whichever site you choose
$backend = "place your rss feed here inside the quotes"; //change this to match the rss feed url you wish to display.
// end
function endtheElement($parser, $tagName) {
// This function is used when an end-tag is encountered.
global $insideitem, $tag, $title, $description, $link;
if ($tagName == "ITEM") {
echo '<table width="100%" border="0"><tr>
<td class="main-table">
<span class="nav-head"><strong>
';
printf("<p><b><a href='%s'>%s</a></b></p>", // make our title into an actual link
trim($link),htmlspecialchars(trim($title))); // remove html characters from the title
echo "</tr>";
echo '<tr>
<td class="nav">';
printf("<p>%s</p>",$description); // Print out the live journal entry
echo"</td>";
echo "</tr>";
echo "</table>";
echo "<br>";
$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);
Hey thanks! That works nicely :up: Just a note to the developers though. From a users perspective it would be really nice to have the same RSS Feed option that is in the block manager when creating articles. BTW, is there actually anyway to define blocks that are only used on certain custom pages and not all the time?
Anyway to limit the lines pulled to say 10 articles or character limit?
have a look in the block code snippets board http://www.tinyportal.net/index.php?board=46.0 you may find something there
Thank you!!!