I'm starting a new segment on this blog today called "CaRP In The Wild" where I'll spotlight noteworthy uses of CaRP. First up is Shawn Collins' website for his Affiliate Summit conference. It's a semi-annual event (once in the west and once in the east) that pulls in thousands of participants (you can see the massive list on his homepage).

Shawn created a "hash tag" for use on Twitter when talking about the upcoming conference (#asw09 for "Affiliate Summit West '09"), and is using using Twitter's search feed feature along with CaRP Evolution to display the latest tweets containing that tag on the Affiliate Summit homepage.

Shawn emailed me to ask how to fix a few display issues, so we started from the code I use to display my Twitter feed in my blog sidebar, and ended up with this:

<?php
function LinkMyURL($ii,$fn,$iind,$in,$va,$rv) {
    return preg_replace('#.*twitter.com/([^/]+)/.*#', '\\1: ',
    		$GLOBALS['carpconf']['rssparser']->GetFieldValue('url')).
    	preg_replace('#(http://[-\\w./]{1,22})([-\\w./]*)#',
    		'<a target="_blank" href="\\1\\2">\\1</a>', $va['TITLE']);
}

function DoMyConfig() {
    CarpConf('iorder','image,url,date,mytitle');
    CarpRegisterCallback('','LinkMyURL','handlefield','mytitle');

    CarpConf('cborder','');
    CarpConf('idateformat','j-M@g:ia');
    CarpConf('aidate','</i> - ');
    CarpConf('ai','<br style="clear:left;" /><br />');
    CarpConf('maxitems',5);
    CarpConf('encodingout','UTF-8');
    CarpConf('biurl','<a target="_blank" href="');
    CarpConf('aiurl','">Go &raquo;</a> ');
	CarpConf('biimage', '<div style="float:left;margin-right:10px;">');
	CarpConf('aiimage', '</div>');
	CarpConf('timeoffset', -300);
}

require_once '/PATH/TO/carp/carp.php';

CarpRegisterCallback('','DoMyConfig','cachemiss','');

CarpCacheShow('http://search.twitter.com/search.atom?q=%23asw09','twitter_asw09');
?>

It's a great example of using CaRP with a social media site to add relevant, auto-updating content to your website.

Reader Comment:
Andy said:
great info... thanks
(join the conversation below)