> 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

Attachment: signature.asc
Description: PGP signature

Reply via email to