First of all, don't assume things are not working just because it doesn't
work for you:

http://bakery.cakephp.org/comments.rss

That's an RSS feed generated with CakePHP 1.2 and works like a charm. So you
know this is how it works:

On app/config/routes.php add:

Router::parseExtensions( 'rss' );

Then on CommentsController there's this (I removed some things for
readability):

function index($articleId = null) {
        $conditions = array('Comment.published' => 1);
                
        $this->Comment->recursive = 0;
        $this->set('comments', $this->Comment->findAll($conditions, null,
'Comment.created DESC, Comment.id DESC', 15));
}

Then on app/views/comments you have an "rss" folder, and inside an index.ctp
file that reads:

<?php
if (!empty($comments)):
        $this->pageTitle = 'Latest Bakery Comments';
        echo $rss->items($comments, 'transformRSS');
endif;

function transformRSS($comment) {
        return array(
                'title' => $comment['Comment']['title'],
                'link' =>
array('url'=>'/articles/view/'.$comment['Article']['slug'].'#comment-'.$comm
ent['Comment']['id']),
                'description' => substr($comment['Comment']['body'], 0,
200),
                'pubDate' => date('r',
strtotime($comment['Comment']['created'])),
        );
}
?>

-MI

---------------------------------------------------------------------------

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 

BAKE ON!

blog: http://www.MarianoIglesias.com.ar


-----Mensaje original-----
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
de Thomas
Enviado el: Lunes, 14 de Mayo de 2007 08:45 a.m.
Para: Cake PHP
Asunto: rss building with rss-helper in 1.2 does not work

I am trying to get the rss working with the help of the rss-helper of
1.2, but somehow cake doesn't spit out valid rss.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to