Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Please help me understand URL and Routes in Cake
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Chris Lamb  
View profile   Translate to Translated (View Original)
 More options 28 Feb 2007, 15:54
From: Chris Lamb <ch...@chris-lamb.co.uk>
Date: Wed, 28 Feb 2007 15:54:36 +0000
Local: Wed 28 Feb 2007 15:54
Subject: Re: Please help me understand URL and Routes in Cake

> 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
< 1K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google