Hi all,

I've found a minor problem that is currently unsolvable with Agavi  
routing [1]: A client wishes to have all urls end in '.html' for SEO  
purposes. Well, pretty much all - rss feeds and some xml feeds need  
to end in '.rss' and '.xml'. So I currently have the option of  
putting an optional '.html' on each and every route which is a  
problem with nested routes and all the like and not the nicest  
solution in itself.

For RSS feeds we always propagate a solution like that:

<route name="output_rss" pattern=".rss$" output_type="rss" cut="true"  
stop="false" />

I tried the same for html:

<route name="output_html" pattern=".html$" output_type="html"  
cut="true" stop="false" imply="true" />

I need to set 'imply' so that I don't have to change all gen() calls  
to 'foo+html'. But now, the route 'foo+rss' renders as 'foo.html.rss'  
or 'foo.rss.html' depending on the order I define the routes. This is  
not intended. Callbacks don't help as they don't know what the  
originally generated route was.

So I've been digging around in the agavi source - there are two  
options that I came up with.

A) Make all gen() calls and the callback's onGenerate() aware of what  
the originally passed route to gen() was - 'foo+rss' in the example  
above. That's an API change, quite a lot of work and potential pain.

B) As the problem only occurs with implied routes (all others have to  
specified explicitly anyways) there could be an option  
'exclude_implied' for the route:

<route name="output_rss" pattern=".rss$" output_type="rss" cut="true"  
stop="false" exclude_implied="output_html" />

This would suppress the rendering of the implied route output_html  
when the route 'output_rss' gets rendered - unless +html is specified  
explicity on gen() or on gen(null) calls.

exclude_implied could only be specified on routes that don't have the  
'implied' attribute set and accepts a whitespace delimited list of  
implied routes that do not get generated when the route is generated.

This way, the code changes would only happen in  
AgaviRouting::getAffectedRoutes() where the implied routes get pulled  
in the array of routes to generate and a minor tweak to the schema  
and the config handler. It would solve the problem in a nice and  
isolated way, without need to create callbacks and the like - all  
that's left to the user is a little bit of config work.

Any thoughts on that (maybe there's an easy way that works without  
changes and I just overlooked that...)

Cheers

felix

[1] to the best of my knowledge ;)

_______________________________________________
Agavi Dev Mailing List
[email protected]
http://lists.agavi.org/mailman/listinfo/dev

Reply via email to