No one?
Surely someone can offer some additional insights on this. Thanks. On Mar 1, 10:44 am, "barduck" wrote: > Thanks for the reply. > > I think I have better understanding of the Route functionality now. > > I am still not sure I understand the full potential of regular > expressions in Route. I mean, I see how I can specify a regex in the > matching part of the Route->connect() but in mod rewrite, I can use > regular expression both in the matching and the substitutions part of > the URL (the groups from the match can be used in the rewritten URL, > using (...) in the pattern and $N in the substitution), can something > like this be done in Route? > > I assume the colon is one way to do this, but does colon-param pattern > always needs to come surrounded by slashes (/)? What about the > asterisk I used in my route, how come it isn't being confused with the > meaning of asterisk in regex? > > I am also not sure what is the best way to achieve what I described in > my original post. One possible solution is to define one big parameter > and parse it myself in my code using a delimiter I set. > > So I set unit1+unit2+unit3... as one big parameter and separate it in > code myself by the plus signs. Then I set a Route rule to detect plus > signs before the normal unit view match. I think this will work also > for the parameters to the index view but I wonder if this is the right > way to do this and whether cake can do it automatically for me? > > Thanks. > > - barduck > > On Feb 28, 5:54 pm, Chris Lamb <[EMAIL PROTECTED]> wrote: > > > > I understand that Cake does [routing] this in two phases, one > > > using apache mod rewrite to pass the rest of the path to cake and the > > > second one by "Routes" to further route the URL in cake internally. Is > > > this correct? > > > Yes. > > > > I assume that the major purpose of the Routes is to map URLs to > > > controllers, functions and parameters. > > > Correct. > > > > 1. I've seen a colon (:) used in the manual in routes config (like / > > > blog/:action/* ). What is the special meaning of the colon? It isn't > > > mentioned anywhere. > > > They are to control the parameters that are passed to the Controller. > > I think the syntax is a Ruby-ism. First, the general case. If your > > route is: > > > /blog/:spam/* > > > then if the browser requested > > > /blog/eggs/ > > > then $this->params['spam'] would contain the value 'eggs'. You can have > > more than one in the route. For example: > > > /blog/:year/:month/:day/:slug/* > > > gets you something like the default WordPress blog link structure. > > There are two 'magic' parameters, "controller" and "action" which, when > > set, decide which controller or action to call respectively. For > > example, the route: > > > /blog/:action/:spam > > > when called with: > > > /blog/view/eggs/ > > > will call the "view" action with $this->params['spam'] set to "eggs". > > > > 2. Can I use regular expressions in Routes like on mod rewrite? How? > > > The manual doesn't mention it. > > > Just use regular Perl-compatible regexs. > > > > 3. Can I still use URL query string parameters using "?" ? Or does > > > cake only use the /controller/action/param/param... convention? > > > Cake has a different method of handling query string parameters. My > > advice is to construct a controller action to display $this->params and > > see how they are handled. > > > > Hope I am making myself clear. Sorry for the long message. > > > Hopefully someone else can help with the rest if the above does not > > help you solve the problem yourself. Note that the CakePHP source is > > very readable for a PHP program, so examining the dispatcher code may > > make sense than any of this. > > > Best wishes, > > > -- > > Chris Lamb, Leamington Spa, UK GPG: 0x634F9A20 > > > signature.asc > > 1KDownload --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
