Hi,

I am trying to understand how friendly URLs and "Routes" work in Cake
and have few of questions that might be trivial but I can't seem to
find an answer in the documentation.

I am familiar with url rewriting from other platforms where I used a
similar functionality of mod rewrite to map logical URLs to physical
server paths. I understand that Cake does 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?

I assume that the major purpose of the Routes is to map URLs to
controllers, functions and parameters.

Questions:

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.
2. Can I use regular expressions in Routes like on mod rewrite? How?
The manual doesn't mention it.
3. Can I still use URL query string parameters using "?" ? Or does
cake only use the /controller/action/param/param... convention?

And now to a real example:

Suppose I have a Model called Unit, so I would like to have a view to
show multiple units in table, with various filters and sorted
parameters, and a view that shows the information on a single unit.

So, I'd like to have the following URLs
/units    - for a view showing a table of multiple units
/units/<unit name>    - for a view of the single unit (no, I don't
want to use the action in the URL like /units/view/<unit name>, I'd
like to keep this one as short and simple as possible)

I defined the following Routes:

$Route->connect('/units', array('controller' => 'units', 'action' =>
'index'));
$Route->connect('/units/*', array('controller' => 'units', 'action' =>
'view'));

So far everything works fine.

Now I would like to accomplish 2 additional things:

1. Have parameters passed to the /units/ index view (like filters and
sort columns) on the URL. I would normally do this with query string
parameters:
/units?sort=column&filer=.....&...
How do I do this in Cake so it doesn't interfere with the single unit
view?

2. I would like to be able to pass multiple units to the index view
and show these units in the same multiple units table (with unknown
parameter count). Like this
/units/unit1+unit2+units3
OR
/units/unit1/unit2/unit3/...

How do I define unknown count of parameters in Routes and how do I do
this without interfering with the single unit view?


Hope I am making myself clear. Sorry for the long message.

Thanks in advance!

- barduck


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to