This works, but it leads to url's like: /nieuws//rss Still not as elegant as I'd like. Is there a way to make one of those slashes disappear if the parameter is not set? Or should I just define a special route for the rss page?
Koen > -----Oorspronkelijk bericht----- > Van: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Namens David Zülke > Verzonden: woensdag 24 januari 2007 12:15 > Aan: Agavi Users Mailing List > Onderwerp: Re: [Agavi-Users] Generating a RSS feed > > Koen, > > what you can do here is > > $r->gen('Nieuws+rss', array('page' => null)); > > that will skip the page parameter, which should then be empty > since it's an optional subpattern. > > Let me know if that works. > > Cheers, > > David > > > Am 24.01.2007 um 10:16 schrieb Van Daele, Koen: > > > David, > > > > Thanks for the explanation. Works like a charm. > > One more question: is it possible to have a parameter in a > route that > > only appears for a certain ouptut type. > > E.g.: I have the route > > <route name="Nieuws" pattern="^/nieuws/(page:\S+)?" > > module="Algemeen" action="NieuwsTonen> > > <defaults> > > <default for="page">1</default> > > </default> > > </route> > > > > Combined with the rss output type this gives url's like /nieuws/1/ > > rss. This is not very elegant and the page parameter is > actually only > > relevant for the html output (sine that is paged, but rss just > > displays the latest X news items). > > > > Greetings, > > Koen > > > > P.S.: I already had a baseview, but I did not have the setup with > > executeHtml(). Thanks for the tip. > > > > > >> -----Oorspronkelijk bericht----- > >> Van: [EMAIL PROTECTED] > >> [mailto:[EMAIL PROTECTED] Namens David Zülke > >> Verzonden: maandag 22 januari 2007 13:58 > >> Aan: Agavi Users Mailing List > >> Onderwerp: Re: [Agavi-Users] Generating a RSS feed > >> > >> 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 > >> > > > > _______________________________________________ > > users mailing list > > [email protected] > > http://lists.agavi.org/mailman/listinfo/users > > > > > _______________________________________________ > users mailing list > [email protected] > http://lists.agavi.org/mailman/listinfo/users > _______________________________________________ users mailing list [email protected] http://lists.agavi.org/mailman/listinfo/users
