Hello everyone,
Just registered an account with webmaster-talk after spending hours searching for a solution to my problem.
I downloaded Smarty and MagpieRSS used to make running RSS Feeds really easy. It works fine if I want all the news scripts to show up, it also works fine if I want one.
I want to have 1-3 news feeds on front page. 8-10 on individual page.
Doing some research on my own, for hours. I discovered a few 'solutions' to limit the amount of items parsed by magpierss. I just can't seem to get it to work, here is what I was told to do:
Code:
You want to display the 10 (or 3) most recent headlines, but the RSS feed
contains 15.
SOLUTION:
$num_items = 10;
$rss = fetch_rss($url);
$items = array_slice($rss->items, 0, $num_items);
Here is my code:
Code:
<?
$mydir = "/rss";
require_once($_SERVER["DOCUMENT_ROOT"].$mydir."/Smarty/libs/Smarty.class.php");
require_once($_SERVER["DOCUMENT_ROOT"].$mydir."/magpierss/rss_fetch.inc");
$tpl = new Smarty();
$tpl->template_dir = $_SERVER["DOCUMENT_ROOT"].$mydir.'/templates/';
$tpl->compile_dir = $_SERVER["DOCUMENT_ROOT"].$mydir.'/templates_c/';
$tpl->config_dir = $_SERVER["DOCUMENT_ROOT"].$mydir.'/configs/';
$tpl->cache_dir = $_SERVER["DOCUMENT_ROOT"].$mydir.'/cache/';
$url = "http://www.abc.net.au/news/indexes/westernvic/rss.xml";
$num_items = 10;
$rss = fetch_rss($url);
$items = array_slice($rss->items, 0, $num_items);
// echo "<pre>"; print_r($rss); echo "</pre>";
if ($rss) {
define('magpie_cache_age', 1800); # 30 x 60 = 1800 seconds
$tpl->assign("feedtitle",$rss->channel["title"]);
$tpl->assign("items",$rss->items);
}
else {
$tpl->assign("feedtitle","Problem with: $url");
}
$feedhtml = $tpl->fetch($_SERVER["DOCUMENT_ROOT"].$mydir."/templates/newslist.html");
echo $feedhtml;
?>
Thanks in advance if we are able to find a solution.
- Solipsist
Last edited by solipsist; 05-17-2009 at 10:04 PM..
Reason: Thanks in advance!
|