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'],
    ));
}

?>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to