CMSB Into SimplePie

2 posts by 2 authors in: Forums > CMS Builder
Last Post: February 7, 2012   (RSS)

By KCMedia - February 7, 2012

Hi

i have this code for simple pie that i am calling once into all the pages for my site but how can i make it so i can call the url feeds from cmsb that i have setup.

here is the simplepie code

<?php

// get simplepie library
require_once('includes/simplepie.inc');

// new simplepie
$feed = new SimplePie();

// set which feed to process.
$feed->set_feed_url(array(
'http://www.cricket.com.au/RSS',
'http://www.cricketworld.com/feed/rss/news.xml'
));

$feed->enable_cache(true);
$feed->set_cache_location('rss-cache');
$feed->set_cache_duration(1800);

// run simplepie.
$feed->init();

// handle feed type
$feed->handle_content_type();

?>

and here is the cmsb for the rss feed data

<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/driverav/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($rss_feedsRecords, $rss_feedsMetaData) = getRecords(array(
'tableName' => 'rss_feeds',
));

?> <!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>RSS Feeds - List Page Viewer</h1>
<?php foreach ($rss_feedsRecords as $record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Title: <?php echo $record['title'] ?><br/>
Feed URL: <?php echo $record['feed_url'] ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>

<hr/>
<?php endforeach ?>

<?php if (!$rss_feedsRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->

I need to replace just the feed process lines to drag in the feeds.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] CMSB Into SimplePie

By (Deleted User) - February 7, 2012

Hi Craig,

I would suggest the following:
// create an array to store the rss feed urls from CMSB
$rssFeedArray = array();

// load the rss feeds from cmsb....

....
<?php foreach ($rss_feedsRecords as $record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Title: <?php echo $record['title'] ?><br/>
Feed URL: <?php echo $record['feed_url'] ?><br/>
<?php $rssFeedArray[]= $record['feed_url']; ?>

....

// run the simplepie code
....

// set which feed to process.
$feed->set_feed_url($rssFeedArray);
...


This is just a quick idea - try dropping the above into your pages and it should work. The only proviso is that you have to load the data from CMSB first. You don't have to output anything though, you can just loop over the records to get the rssFeedUrls and add them to the rssFeedArray array.

Let me know if this helps,

Tom