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
Getting Started: Free Download | Purchase | Install
Reference: Functions | Plugins | Themes | Full Index
Etc.: Display Formatting | Example Code | Affiliates
CarpMapField( CaRP field name, RSS field name [, is a channel field [, priority]] );
Set up a mapping between an RSS element or attribute and one of CaRP's internal data fieldsEvolution | LE | Koi | SE |
All | n/a | >=3.2 | n/a |
Changes the mapping of RSS fields to CaRP's display fields in order to handle incorrectly formatted newsfeeds, and to provide compatibility with extensions to RSS not supported by the CaRP's default configuration.
Arguments:
- CaRP field name: One of the following: url, title, desc, date, imageurl, imagelink, imagealt, imagewidth, imageheight; and for items (but not the channel): author.
- RSS field name:
This argument is either a string or (as of CaRP 3.5.11) an array.
If it is a string, it is the name of the field from the RSS file, including the names of the parents of the field, as follows:
- For top-level children of the channel or of an item, just use the name of that field.
- For anything below the top level, concatenate the names of each containing field, separating each with a "caret" character (^). For example, for an item's image's width, "IMAGE^WIDTH", or for an IMAGE:ITEM's DC:TITLE, "IMAGE:ITEM^DC:TITLE". You may also map attributes, for example, the RDF:RESOURCE attribute of an IMAGE:ITEM would be specified as "IMAGE:ITEM^RDF:RESOURCE".
- The name of an RSS element or attribute, specified as described above.
- A "regular expression" which the value of that element or attribute must match for the mapping to succeed. The regular expression must include the delimeters surrounding it, and may be followed by pattern modifiers according to the syntax specified by the PHP documentation.
- is a channel field: By default, CaRP assumes that you wish to map an item field. To set the mapping for a channel field, enter 1 here. The default (an item field) is 0.
- priority: Since more than one RSS field may be mapped to the same output field, CaRP must be able to decide which to display if the newsfeed specifies more than one. By default, CaRP places lower priority on fields mapped using this function than on it's default field mapping. To override this default, set the value of priority to a number 6 or higher. You may specify any number of mappings to the same CaRP display field, and use the priority setting to determine which to display when more than one is present.
Return value: none
Usage Examples:
<?php require_once '/home/geckotribe/carp/carp.php'; CarpMapField('desc','content:encoded',0,10); CarpCacheShow('http://www.geckotribe.com/press/rss/pr.rss'); ?>
<?php require_once '/home/geckotribe/carp/carp.php'; CarpMapField('podcast',array('enclosure^url','enclosure^type','#^audio/#i')); CarpCacheShow('http://www.geckotribe.com/press/rss/pr.rss'); ?>