I have a semi-related routing question which I would like to
piggy-back on this thread. :-)
I would like to make routes which behave like regular directory names
typically do, in that the closing slash is optional. I see two ways
of doing this right now:
1) Using the technique you just described, and trimming the closing
slash off the parameter once it has been loaded in the action.
2) Creating two routes like so:
test1:
url: /test/:slug
param: { module: blog, action : test }
test1_trailing_slash:
url: /test/:slug/
param: { module: blog, action : test }
However, I am shockingly lazy and I was hoping there was some way of
describing a route with some optional text that would appear after the
parameter but would not be included in the parameter. Something along
the lines of this:
test1:
url: /test/:slug[/]
param: { module: blog, action : test }
This route would be matched by /test/whatever as well as
/test/whatever/, and the parameter 'slug' would have the same value in
both cases.
Is there a way to accomplish this in symfony 1.0.x?
David
On 10/29/07, Francois Zaninotto <[EMAIL PROTECTED]> wrote:
> Hi pookey,
>
> Long time no see :).
>
> To match a parameter with slashes inside, you must add a requirement on it
> to make it greedy:
>
> test1:
> url: /test/:slug
> param: { module: blog, action : test }
> requirements: { slug: '.*' }
>
> Have a look at sfSimpleCMSPlugin, it does exactly that in its
> config/config.php.
>
> Cheers,
>
> François
>
>
> 2007/10/29, Ian P. Christian < [EMAIL PROTECTED]>:
> >
> > I think I've asked this before, but I forget the answer :)
> >
> > I want to match something with /'s in URL - and I've kinda got something
> > that works, but it's ugly.
> >
> > in my routing , I can do this:
> >
> > test1:
> > url: /test/*
> > param: { module: blog, action : test }
> >
> >
> > which means from my action, I can get getPathInfo();
> >
> > For a URL like 'http:// .. /test/moo/cow', the getPathInfo will return
> > '/test/moo/cow', which I can then trim off the 'test' and use it as
> > required.
> >
> > BUT - this means the action is no longer de-coupled from the routing,
> > the action needs to know the URL, which is poor design.
> >
> > I *think* this issue is resolved in sf1.1's better routing (is it?), but
> > what options are there for a sf1.0 user?
> >
> > Thanks,
> >
> > --
> >
> > Ian P. Christian ~ pookey.co.uk
> >
> >
> >
> >
> >
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---