routes and urlRewriteFilter advice

26 views
Skip to first unread message

Matthew Abbott

unread,
Feb 9, 2012, 9:26:23 AM2/9/12
to framework-one
All,

Im trying to mix a urlRewriteFilter with the routes system in FW/1.
Im wondering if there is a better way to do this.

Here is my views folder

views
-groups
-mygroup.cfm


What im trying to do is set the url to be

mysite.com/myapp/index.cfm/mygroup/foo

this url would translate to
mysite.com/index.cfm?action=groups.mygroup&id=foo

I added the following route
'/mygroup/:id'='/groups/mygroup/id/:id'

Im using the urlRewriteFilter to remove the index.cfm from the url.

What i noticed is now the buildUrl('section.item') will not work for
the groups section

This will not work
buildUrl(action='groups.mygroup',queryString='id=foo')

This will work
buildUrl(action='mygroup.foo')

Is this the best way of doing this? Are there any gotchas ill need to
be aware of?

Any help is greatly appreciated

-Matthew

Sean Corfield

unread,
Feb 9, 2012, 12:05:10 PM2/9/12
to framew...@googlegroups.com
On Thu, Feb 9, 2012 at 6:26 AM, Matthew Abbott <dduc...@gmail.com> wrote:
> What i noticed is now the buildUrl('section.item')  will not work for
> the groups section

Well, buildURL() doesn't know how to generate routes (and in general
routes can't be "run in reverse" because it's not a 1:1 mapping) so if
you're using routes you have two choices:
* buildURL() with fake actions that (mostly) match routes - you won't
be able to do this in general for all routes because routes don't
match actions!
* construct URLs yourself

(anyone who believes you can run routes backward to generate correct
routes from "regular" URLs hasn't done much work with routes so think
carefully about edge cases before you suggest that as a possible
enhancement :)
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Reply all
Reply to author
Forward
0 new messages