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

See the Page plugin in action

Page

Page is a plugin bundled with CaRP Evolution 4.0.12 and higher. It makes it easy to enable your website visitors to navigate through the items in a feed a page at a time, displaying a limited number of items on each page.
 

Installation:


To install Page, if "page.php" is not already found in your "plugins" folder, upload it to that folder.
 

Use:


To tell CaRP Evolution to use the Page plugin (see the example code below for details):
  1. If you are aggregating multiple feeds, prepare them for aggregation as usual using CarpFilter, CarpCacheFilter or CarpGroupFilter.
  2. Load the plugin.
  3. Set CaRP's "maxitems" setting to tell CaRP how many items to display per page.
  4. To tell the plugin how many pages of items to skip (for example, to display the second page, tell it to skip 1 page), do one of the following:
    • Set the plugin's "skip-pages" setting ($carppageconf['skip-pages']).
    • Use the CarpPageLinks function (see below).
  5. Display the feed or feeds using the usual feed display functions (CarpCacheShow, CarpAggregate, etc).

 

Functions:


The Page plugin has a function that generates the links to go to the previous and next pages of items in a feed, as follows:

 

Configuration:


The Page plugin has the following settings, which are members of the array $carppageconf. In most cases, you'll use the function CarpPageLinks to control these settings. All of the settings except "skip-pages" affect only the output of CarpPageLinks:


Example Code:

Assuming the name of your file was "paging.php", you could use this code to display the feed, 5 items to a page, with bold, enlarged paging links centered above and below the feed:

<?php
$page=isset($_GET['page'])?$_GET['page']:0;
require_once '/YOUR/PATH/TO/carp/carp.php';
CarpConf('maxitems', 5);
CarpLoadPlugin('page.php');
$pagelinks='<p style="font-weight:bold;text-align:center;font-size:115%;">'.
	CarpPageLinks('paging.php', $page).'</p>';

echo $pagelinks;
CarpCacheShow('http://example.com/the-feed.rss');
echo $pagelinks;
?>

To have CarpPageLinks attempt to determine whether or not there are enough items in the feed to display a "next" link, set CaRP's "outputformat" setting to 2, set $carppageconf['skip-pages'], call the display function, then call CarpPageLinks with "-2" as the final argument:
<?php
$page=isset($_GET['page'])?$_GET['page']:0;
require_once '/YOUR/PATH/TO/carp/carp.php';
CarpConf('maxitems', 5);
CarpConf('outputformat', 2);
CarpLoadPlugin('page.php');
$carppageconf['skip-pages']=$page;
CarpCacheShow('http://example.com/the-feed.rss');
$pagelinks='<p style="font-weight:bold;text-align:center;font-size:115%;">'.
	CarpPageLinks('paging.php',$page,'','','','page',-2).'</p>';
echo $pagelinks.$carpoutput.$pagelinks;
?>

When aggregating multiple feeds, be sure to set "maxitems" to the maximum number of items you wish displayed for any particular feed before calling the "filter" function. After calling the filter function, set it to the total number of items to display per page.
<?php
$page=isset($_GET['page'])?$_GET['page']:0;
$feeds=array(
	'http://www.geckotribe.com/press/rss/pr.rss'=>'gt-pr',
	'http://www.example.com/rss/feed1.rss'=>'ex-1',
	'http://www.example.com/rss/feed2.rss'=>'ex-2',
	'http://www.example.com/rss/feed3.rss'=>array('ex-3','ISO-8859-1'),
	'http://www.example.com/rss/feed4.rss'=>array('ex-4','US_ASCII'),
);

require_once '/YOUR/PATH/TO/carp/carp.php';
CarpConf('maxitems',10);
$cachefiles=CarpGroupFilter($feeds);

CarpLoadPlugin('page.php');
CarpConf('maxitems',15);
$pagelinks='<p style="font-weight:bold;text-align:center;font-size:115%;">'.
   CarpPageLinks('paging.php', $page).'</p>';

echo $pagelinks;
CarpAggregate($cachfiles);
echo $pagelinks;
?>