CaRP Evolution Documentation
CaRP Evolution Documentation
twitter youtube linkedin google-plus
CaRP Evolution Box
Web This Site

CaRP: Caching RSS Parser - Documentation


CaRP Interactive FAQ
Getting Started: Free Download | Purchase | Install
Reference: Functions | Plugins | Themes | Full Index
Etc.: Display Formatting | Example Code | Affiliates

Aggregation Example

This code will select items containing any of the words "Microsoft", "Oracle", "Sun", or "IBM" in either the title or description from two different newsfeeds, and display the four most recent. Note that the newsfeeds must contain either a pubDate or dc:date field for their items in order to correctly select the most recent stories:

<?php
require_once "/path/to/carp.php";

// don't display any channel fields
CarpConf('cborder','');

// display a bullet before each item
CarpConf('bi','&bull ');

// set up the filtering
CarpConf('filterin','microsoft|oracle|sun|ibm');

// show up to 4 items
CarpConf('maxitems',4);

// show upt o 100 characters from the description
CarpConf('maxidesc',100);

// refresh every 2 hours
CarpConf('cacheinterval',120);

// Filter each newsfeed and cache the results
CarpCacheFilter("http://slashdot.org/index.rss", "agg2-slashdot");
CarpCacheFilter("http://www.infoworld.com/rss/columnists.rdf", "agg2-infoworld");

// combine the results from the two newsfeeds
CarpAggregate('agg2-slashdot|agg2-infoworld');
?>