
320,047 Downloads
Joomla! 2.5.x & 3.x
Version 3.0.5
Download
Joomla! 1.5.x
Version 2.0.6
Download
Overview
Concise Guide
Installation in J!1.0
Usage for J!1.0
Installation in J!1.5
Usage for J!1.5
Upgrades
Troubleshooting
Tutorial
Security Checklist
Jumi 2.1 Guide
News
Blog
Whishlist
Change Logs
About
Acknowledgements
Downloads
Development
Feedbacks
Forum
Basic script to grab the results from a RSS feed. Results are cahced for two hours (by default) so no bandwidth issues!
rss_grabber.php
You need to create new Jumi application with the following code below.
You can add the /* config */ part of the script to Custom Script field, for making changes easily from the Joomla! admin interface. Otherwise you need to edit the rss_grabber.php file every time you need to make changes.
<?php defined("_JEXEC") or die("Restricted access"); ?> <?php /* config */ $rss_url = "http://edo.webmaster.am/rss"; $file_name = 'cache/'.md5($rss_url); $cache_time = 2*60*60; // 2 hours // check cache if(file_exists($file_name) and strtotime('now') - filemtime($file_name) < $cache_time) { $rss = file_get_contents($file_name); } else { // retrieve feed from server $rss = file_get_contents($rss_url); // cache content if(strlen($rss) > 3000) file_put_contents($file_name, $rss); } $rss = simplexml_load_string($rss); echo '<h1 style="border-bottom:2px solid threedlightshadow;font-size:160%;margin:0 0 0.2em;">', $rss->channel->title, '</h1>', "\n"; echo '<h2 style="color:threeddarkshadow;font-size:110%;font-weight:normal;margin:0 0 0.6em;">', $rss->channel->description, '</h2>', "\n"; foreach($rss->channel->item as $item) { echo '<div class="entry">', "\n"; echo '<h3><a href="', $item->link, '">', $item->title, '</a><div style="font-size:85%;font-weight:normal;">', $item->pubDate, '</div></h3>', "\n"; echo '<div base="', $rss_url, '" style="font-size:110%;">', $item->description, '</div>', "\n"; echo '</div>', "\n"; }
Your host must support PHP SimpleXML library.
RSS version need to be 2.0
Acknowledgements
- Thanks to IceCreamAzzazzin for the idea.