Help needed with maxWords and image in RSS feed

3 posts by 3 authors in: Forums > CMS Builder
Last Post: June 13, 2017   (RSS)

By AlanAlonso - June 13, 2017

That's easy just remove the image from the content field, and add a upload field just for the image.

<rss version="2.0">
  <channel>
    <title>Bridlington Entertainment</title>
    <link>http://www.lpl-testsite.co.uk/</link>
    <description>Whats on Guide for Bridlington</description>
    <pubDate><?php echo date('r') ?></pubDate>
    <language>en-us</language>

    <?php foreach ($current_newsRecords as $record): ?>
    <item>
      <title><?php echo htmlencode($record['title']) ?></title>
      <link>http://<?php echo $_SERVER['HTTP_HOST']; ?><?php echo $record['_link'] ?></link>
      <description>  <![CDATA[<?php echo maxWords ($record['content'],60) ?> <a href="http://<?php echo $_SERVER['HTTP_HOST']; ?><?php echo $record['_link'] ?>" target="_blank">Read more..</a>]]></description>
      <image>
    <url><?php echo $record['upload'] ?></url>
    <title><?php echo htmlencode($record['title']) ?></title>
    <link>http://<?php echo $_SERVER['HTTP_HOST']; ?><?php echo $record['_link'] ?></link>
  </image>

      <pubDate><?php echo date('r', strtotime($record['createdDdate'])) ?></pubDate>
      <guid isPermaLink="false"><?php echo $record['_link'] ?></guid>
    </item>
    <?php endforeach ?>
  </channel>
</rss>

By Damon - June 13, 2017

Hi,

I agree with Alan's suggestion to use a separate field for image upload to include in the RSS. 

If you already have images in the rich text editor, they are getting stripped out so they can be left in as is for the main site. The additional image upload field could be used just for including image content to the RSS feed.

Cheers,
Damon Edis - interactivetools.com

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