I'm having the same issue. I'm assuming it can be done via elem method of
the Rss Helper class.
http://api20.cakephp.org/file/Cake/View/Helper/RssHelper.php# (scroll down
to the Rss helper class info). Here's what I have in my rss.ctp file but I
can't get the elem method to work properly:
<?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)
));
}
?>
On Tuesday, April 17, 2012 4:21:48 AM UTC-4, Reza Talamkhani wrote:
>
> Hi, how can I insert images in my rss feed? I want one image to go
> with each post.
>
> index.ctp
>
> <?php
> $this->set('documentData', array(
> 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/'));
>
> $this->set('channelData', array(
> 'title' => __("پست های اخیر رضا تلم خانی"),
> 'link' => $this->Html->url('/', true),
> 'description' => __("وب سایت رسمی رضا تلم خانی"),
> 'language' => 'fa'));
>
> App::uses('Sanitize', 'Utility');
> foreach ($posts as $post) {
> //$postTime = strtotime($post['Post']['created']);
>
> $postLink = array(
> 'controller' => 'posts',
> 'action' => 'view',
> $post['Post']['id'],
> //'year' => date('Y', $postTime),
> //'month' => date('m', $postTime),
> //'day' => date('d', $postTime),
> //$post['Post']['slug']
> );
>
> // This is the part where we 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']['body']);
> $bodyText = strip_tags($bodyText);
> $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' => $postLink,
> 'guid' => array('url' => $postLink, 'isPermaLink' => 'true'),
> 'description' => $bodyText,
> 'creator' => $post['User']['full_name'],
> 'pubDate' => $post['Post']['created'],
> ));
> }
>
> ?>
>
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.