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: [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?

Re: [design9] RSS Feed

By Jason - February 14, 2012

Hi April,

There are specific tags to display an image in an RSS feed. Take a look at this:

http://www.w3schools.com/rss/rss_tag_image.asp

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/