I'm trying to add images to my rss feed and I'm assuming that it can be done using the elem method of the rss helper but I don't know how to use elem method properly. If images are add a different way then please explain as well. This is my rss.ctp view file:
<?php
App::uses('Sanitize', 'Utility');
$this->set('channelData', array(
'title' => 'test',
'link' => 'test',
'url' => 'test',
'description' => 'test',
'language' => 'en-us',
'managing-editor' => 'test',
));
foreach($posts as $post) {
// Clean the body text for output as the description of the rss item,
// this needs to have only text to make sure the feed validates
$bodyText = preg_replace('=\(.*?\)=is', '', $post['Post']['excerpt']);
$bodyText = $this->Text->stripLinks($bodyText);
$bodyText = Sanitize::stripAll($bodyText);
$bodyText = $this->Text->truncate($bodyText, 400, array(
'ending' => '...',
'exact' => true,
'html' => true,
));
echo $this->Rss->item(array(), array(
'title' => $post['Post']['title'],
'link' => array(
'controller' => 'streams',
'action' => 'view', $post['Post']['id']
),
'guid' => array(
'controller' => 'streams',
'action' => 'view', $post['Post']['id']
),
'description' => $bodyText,
'pubDate' => $post['Post']['post_date'],
//'elem' => array('media:thumbnail', array('url' => $this->Html->url('/app/webroot/'.$post['Post']['image_site_thumb'], true), 'width' => '75', 'height' => '75'), NULL, false)
'enclosure' => 'test'
));
}
?>
Here's the documentation:
http://book.cakephp.org/2.0/en/core-libraries/helpers/rss.html
http://api20.cakephp.org/class/rss-helper
http://api20.cakephp.org/file/Cake/View/Helper/RssHelper.php#
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
Friday, January 11, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment