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

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 fields
EvolutionLEKoiSE
Alln/a>=3.2n/a
Description:
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:
  1. CaRP field name: One of the following: url, title, desc, date, imageurl, imagelink, imagealt, imagewidth, imageheight; and for items (but not the channel): author.
  2. 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".
    If it is an array, the first member of the array is the name of the RSS field as described above. The remaining members describe conditions that must be met for the mapping to succeed. For each condition, the array has two members:
    • 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.
  3. 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.
  4. 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');
?>