RSS example from main page
Here is how the RSS feeds are displayed on the main page. Change the title and feed url (first and fourth lines) and use as many times as you want in a page.If you get a blank space under the feed you are trying to display, reduce the value of $limit until you match the amount on the RSS feed. :) I also use a <style> img {display: none;}</style> at the top of the page to prevent images from being displayed in the news. Cheers.
<p><b>Slashdot</b></p>
<?php
$rss = new DOMDocument();
$rss->load('http://rss.slashdot.org/Slashdot/slashdot');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 20;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
echo '<p>'.$description.'</p>';
}
?>
Check out some other Bands on Bandcamp.com. Crazy Fingers (Vancouver 1991), Altogether Steve and the Mercenaries, and Hammy Ham Hands.
Proudly powered by an IDE, a Text Editor, and some Internet Searches.
2024 dispelled.ca end of file.