Of course, chances are you’re going to want to aggregate multiple feeds and devise some means for viewing them simultaneously. To do so, you can simply modify Listing 20-2, passing in an array of feeds. A bit of CSS may also be added to shrink the space required for output. Listing 20-3 shows the rendered version. Listing 20-3. Aggregating Multiple Feeds with Magpie <style><!-- <?php // Compile array of feeds // Iterate through each feed // Retrieve the feed // Format the feed for the browser foreach ($rss->items as $item) { } ?> Figure 20-3 depicts the output based on these three feeds.
Although the use of a static array for containing feeds certainly works, it might be more practical to maintain them within a database table, or at the very least a text file. It really all depends upon the number of feeds you’ll be using and how often you intend on managing the feeds themselves. Please check back next week for the continuation of this article.
blog comments powered by Disqus |