Tuesday, November 25, 2008

Re: RSS Feed ... what method is called by index.rss

Thank you for the help. You are right that the primary customization I
was interested in was to have a different number of entries used in
the website index vs. the rss index.

Just in case anyone else has the same question, here is what I am now
doing:

-------
// this goes into my Articles::index() method

if( $this->RequestHandler->isRss() ){
$this->paginate['limit'] = 20;
//In Posts Controller
$channelData = array('title' => 'Phrosting Articles',
'link' => array('controller' => 'articles', 'action' => 'feed', 'ext'
=> 'rss'),
'url' => array('controller' => 'articles', 'action' => 'feed', 'ext'
=> 'rss'),
'description' => 'Recent articles posted to Phrosting',
'language' => 'en-us'
);
$data = $this->paginate('Article');
$this->set(compact('channelData', 'data'));
} else {
$data = $this->paginate('Article');
$this->set(compact('data'));
}

---------

On Nov 25, 10:46 pm, "David C. Zentgraf" <dec...@gmail.com> wrote:
> I guess the idea is that the index page and the index RSS feed should  
> very much contain the same data, only in a different output format  
> (layout/view). You can use a paginate() call even for the RSS feed, as  
> you usually only want the last x entries in the feed, not the whole  
> database. You can ask the RequestHandler component whether the page is  
> supposed to be RSS or regular, and increase the limit for the paginate  
> call for example, or set other differentiating options.
>
> If the RSS version is supposed to be completely different from the  
> regular page, just name it something else like feed.rss and have a  
> dedicated feed() action in your controller for it.
>
> On 26 Nov 2008, at 14:28, aranworld wrote:
>
>
>
> > Well, I realize it is a pretty dumb question.  Obviously, the index()
> > method is called when index.rss is accessed.
>
> > I guess my real question is ... what if the logic behind index.rss is
> > different from the logic behind index ... as I'm sure it usually is on
> > websites.
>
> > For example, what if my posts/index uses paginate?  How could I make a
> > controller action called index, that handled both an rss request and a
> > regular request, using different logic for each one?
>
> > -Aran
>
> > On Nov 25, 2:07 pm, aranworld <arancarli...@gmail.com> wrote:
> >> I am finding the manual entry on generating RSS Feeds really helpful
> >> except for one minor detail.
>
> >>http://book.cakephp.org/view/483/Creating-an-RSS-feed-with-the-RssHelper
>
> >> When someone requests posts/index.rss , what controller method is
> >> actually called?  Is Posts::index() called?
>
> >> Where should I put the Controller Code that appears?  If I put it in
> >> Posts::index(), then how do I integrate it with other code for
> >> generating a non-rss feed from Posts::index()?
>
> >> Thanks,
> >> Aran
>
>
--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: