I am in the process of setting up simplepie on my new site. 2 questions:
1. I am using a cron job to cache about 40 feeds hourly. I am planning to show a
"top 10 latest feeds" on the home page and a more detailed listing ( top 20 for
each feed source) on a news page. i know i can use the same cache to drive both
outputs, but i am not sure how the code for the output should be setup. For each
output, i am listing all 40 feeds - using the standard simplepie multifeed array
code. is there a shorter code to simply point to the cache and pull based on a
set criteria without having to list all feed urls for each output?
2. for the detailed news page, i am using the code below (shortened for this
post but there are 48 feeds). you wll notice that there is no set cache location
or feed init e.tc. it seemed to work fine in my wordpress blog. what i am not
sure about is how this is using the cache file? how does it know where to go
find the cache file? my cache file is located in a folder in the root called
"scripts. so i can access it using ./scripts/simplepie_cache/.
But if i add this cache location line to my feed, it throws up errors. if i
remove it, it then seems to be looking for the cache file somewhere else and
throws up errors about not finding the cache file ...
sorry for the long post. i wanted to provide as much info as possible:
<?php
date_default_timezone_set('America/New_York');
require 'simplepie.inc';
$feed1 = new
SimplePie('http://feeds2.feedburner.com/blogspot/tRaA?format=xml');
$feed2 = new SimplePie('http://rss.groups.yahoo.com/group/webanalytics/rss');
$feed3 = new
SimplePie('http://feeds2.feedburner.com/webanalyticsbook?format=xml');
.
.
.
.
.
$feed48 = new SimplePie('http://blogs.msdn.com/excel/rss.xml');
?>
<h1>News</h1>
<div class="simplepie">
<?php if ($feed->error): ?>
<p><?php echo $feed->error; ?></p>
<?php endif; ?>
<div class="simplepie2">
<h2>Source: <a href="<?php echo $feed1->get_permalink(); ?>"><?php
echo $feed1->get_title(); ?></a></h2>
<ol>
<?php foreach ($feed1->get_items(0,5) as $item):?>
<li>
<h4><a href="<?php echo $item->get_permalink(); ?>"><?php echo
$item->get_title(); ?></a></h4>
<p><?php echo shorten($item->get_description(), 150); ?></p>
<p><small>Posted on <?php echo $item->get_date('j F Y | g:i a T'); ?> |
Author: <?php if ($author = $item->get_author()) {echo $author->get_name();} ?>
</small></p>
</li>
<?php endforeach; ?>
</ol>
</div>
.
.
.
.
.
<div class="simplepie2">
<h2>Source: <a href="<?php echo $feed48->get_permalink(); ?>"><?php echo
$feed2->get_title(); ?></a></h2>
<ol>
<?php foreach ($feed48->get_items(0,5) as $item):?>
<li>
<h4><a href="<?php echo $item->get_permalink(); ?>"><?php echo
$item->get_title(); ?></a></h4>
<p><?php echo shorten($item->get_description(), 150); ?></p>
<p><small>Posted on <?php echo $item->get_date('j F Y | g:i a T'); ?> |
Author: <?php if ($author = $item->get_author()) {echo $author->get_name();} ?>
</small></p>
</li>
<?php endforeach; ?>
</ol>
</div>
</div>
y