RSS Feed

4 posts by 3 authors in: Forums > CMS Builder
Last Post: February 14, 2012   (RSS)

1. I am trying to get an image to display in my RSS feed. I have tried the code from one of the other forum posts but nothing shows up.

<description>
<![CDATA[
<?php foreach ($record['image'] as $upload): ?>
<img src="http://www.charlotteparent.com<?php echo $upload['urlPath'] ?>" title="<?php echo $upload['info1'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" /><?php endforeach ?> ]]></description>


Can you tell me what may be wrong?
Here is the full code:
<?php header('Content-type: application/xml; charset=utf-8'); ?><?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>

<?php
require_once "C:/Inetpub/charlotteparent/cmsAdmin/lib/viewer_functions.php";

list($dir_listingsRecords, $dir_listingsMetaData) = getRecords(array(
'tableName' => 'dir_listings',
'where' => "category LIKE '%\tFamily Dining\t%' ",
));

?>

<rss version="2.0">
<channel>
<title>Family Dining and Kids Eat Free | CharlotteParent.com</title>
<link>www.charlotteparent.com/directories/testdining.php</link>
<description>Family Dining</description>
<pubDate><?php echo date('r'); ?></pubDate>
<language>en-us</language>


<?php foreach ($dir_listingsRecords as $record): ?>
<item>
<title><?php echo htmlspecialchars($record['title']) ?></title>
<link><?php echo $record['_link'] ?></link>
<description<![CDATA[
<?php foreach ($record['image'] as $upload): ?>
<img src="http://www.charlotteparent.com<?php echo $upload['urlPath'] ?>" title="<?php echo $upload['info1'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" /><?php endforeach ?> ]]></description>
<pubDate><?php echo date("r", strtotime($record['date'])) ?></pubDate>
<guid isPermaLink="true"><?php echo $record['_link'] ?></guid>
</item>
<?php endforeach ?>



</channel>
</rss>


2. Also, is it possible to include the photo and the summary field with the rss description tag? Like this:
<?php header('Content-type: application/xml; charset=utf-8'); ?><?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>

<?php
require_once "C:/Inetpub/charlotteparent/cmsAdmin/lib/viewer_functions.php";

list($dir_listingsRecords, $dir_listingsMetaData) = getRecords(array(
'tableName' => 'dir_listings',
'where' => "category LIKE '%\tFamily Dining\t%' ",
));

?>

<rss version="2.0">
<channel>
<title>Family Dining and Kids Eat Free | CharlotteParent.com</title>
<link>www.charlotteparent.com/directories/testdining.php</link>
<description>Family Dining</description>
<pubDate><?php echo date('r'); ?></pubDate>
<language>en-us</language>


<?php foreach ($dir_listingsRecords as $record): ?>
<item>
<title><?php echo htmlspecialchars($record['title']) ?></title>
<link><?php echo $record['_link'] ?></link>
<description> <![CDATA[
<?php foreach ($record['image'] as $upload): ?>
<img src="http://www.charlotteparent.com<?php echo $upload['urlPath'] ?>" title="<?php echo $upload['info1'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" /><?php endforeach ?>
]]>
<?php echo ($record['summary']); ?></description>
<pubDate><?php echo date("r", strtotime($record['date'])) ?></pubDate>
<guid isPermaLink="true"><?php echo $record['_link'] ?></guid>
</item>
<?php endforeach ?>



</channel>
</rss>


Thanks!
April

Re: [design9] RSS Feed

By gkornbluth - February 11, 2012 - edited: February 11, 2012

Hi April,

Just a quick guess, but, based on a snippet from the recipe on RSS Feeds in my CMSB Cookbook http://www.thecmsbcookbook.com, I think you may be missing the ">" in the opening description tag and the closing </description> tag.

You can validate your RSS feed before you publish it at: http://www.validator.w3.org/feed/
You can find out more about the tags that are available for use in an RSS feed at: http://www.rss-specifications.com/
<description>
<![CDATA[

<p><u>Here is an image thumbnail</u> </p>

<?php foreach ($record['image'] as $upload): ?>
<img src="http://www.my_web_site.com<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo
$upload['thumbHeight'] ?>" alt="" />
<?php endforeach ?></p>

<p align="center"><strong><font color="#ba1419">My First Image</font></strong></p>
]]>
</description>


Hope that does it,

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] RSS Feed

I fixed the tag but the image still does not appear in RSS feed. Also, is it possible to include a summary and embed photo in description tag?