Hi Koen,

you were right - all you need is a new output type!

First, you have to define that new one (e.g. "rss") in  
output_types.xml. You can define a renderer if you want to use a  
template to generate the output, or you omit the renderer definition  
and use a library to generate the RSS content in the view (even  
though I'm not aware of any PHP libraries that generate RSS).
Next, simply define executeRss() in your View and put the necessary  
code in there.
Now all that's left is to decide that we want RSS as the output type  
and not HTML. To do that, you have several options. You can use the  
routing:
<route name="rss" stop="false" pattern="/rss$" output_type="rss" />
That will set the output type to "rss" for all URLs that end on /rss.  
You can generate such an RSS variant of a URL using $r->gen('routename 
+rss', ...);
Alternatively, you could use a filter, but that's not very elegant.  
The last opportunity to change the output type is in your view's  
initialize method, you could check a request parameter there or  
something. But using the routing is definitely the way to go.

Hope that helps,

David


P.S: it is recommended that you have a MyBaseView from which all  
views extend. This base view has an execute() method that throws an  
exception, or forwards to a 404 action. All your specific views  
implement only executeHtml(), executeRss() etc methods. That way, you  
do not need to worry about the routing setting an output type that  
some of your actions/views do not implement.



Am 22.01.2007 um 08:58 schrieb Van Daele, Koen:

> Hi,
>
> I'd like to make a RSS feed for newsitems. I've already got an  
> action a
> a view to display the html page with the newsitems, but now I'd  
> like to
> generate a feed for this.
>
> Do I need to define a completely different but identical action for  
> this
> or can I reuse the action and e.g. set the output type to rss? Can
> anyone give an example of the different files that need to be altered
> for this (routing, output_types, view, ...)?
>
> Greetings,
> Koen
>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.agavi.org/mailman/listinfo/users
>


_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to