Need Image at Item level in RSS feed

For programming and general questions on Zend Framework

Need Image at Item level in RSS feed

Postby chri1881 on Wed Sep 13, 2017 5:28 pm

Is it possible to add an image to each item/entry in my RSS feed using Zend?

Instead of:
<enclosure url="link here" type="" length=""/>

I need:
<image><url>link here</url></image>

I need it formatted as above for a specific extension we use in our system.

I am using a custom CMS extension in Magento Enterprise 1.14.1.

This is the PHP that builds the feed:

Code: Select all
class SnapAgency_Blog_Block_Rss extends Mage_Core_Block_Template {
    public function _toHtml()
    {
        $newurl = Mage::getUrl('articles/rss');
        $title = Mage::helper('rss')->__('Dayspring Blog Posts');

        $rssObj = Mage::getModel('rss/rss');
        $data = array('title' => $title,
            'description' => $title,
            'link'        => $newurl,
            'charset'     => 'UTF-8',
        );
        $rssObj->_addHeader($data);

        $blogPosts = Mage::getModel('snapagency_blog/post')->getCollection()
            ->addFieldToFilter('published', array('eq' => 1));

        foreach($blogPosts as $blogPost) {
            $image_path = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $blogPost->getFeaturedImage();

            $data = array(
                'title'         => $blogPost->getTitle(),
                'link'          => $blogPost->getPostUrl(),
                'description'   => $blogPost->getExcerpt(),
                'author'        => $blogPost->getWriter(),
                'lastUpdate'       => strtotime($blogPost->getDate()),
                'enclosure'         => array(
                    array(
                        'url'  => $image_path,
                    ),
                ),
            );
            $rssObj->_addEntry($data);
        }

        return $rssObj->createRssXml();
    }
}



I've spent a couple of hours trying to resolve this and haven't gotten anywhere. From what it looks like, Zend does not support <image> for individual entries and has it only at the channel level. :(
chri1881
 
Posts: 1
Joined: Wed Sep 13, 2017 5:19 pm

Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 3 guests