NYCPHP Meetup

NYPHP.org

[nycphp-talk] cake url question

Jon Baer jonbaer at jonbaer.com
Wed Nov 1 10:12:12 EST 2006


You should place them in a central controller or else you will get  
bit later ...

Ie:

example.com/cars/bmw
example.com/cars/toyota
example.com/cars/nissan

In your routes.php:
$Route->connect('/cars/*', array('controller' => 'Car', 'action' =>  
'view'));

In your car controller:
function view($car = '') {
   if ($car) {
      $cars = $this->Car->findAllByCar($car); // (dynamic) available  
in 1.2
   } else {
      $cars = $this->Car->findAll();
   }
   $this->set('cars',$cars);
   $this->render('view');
}

If you *need* to have those URLs instead you can just move the Route  
up one level.

- Jon

On Nov 1, 2006, at 6:27 AM, Marcin Szkudlarek wrote:

> I would like to map multiple url to one controller method like this:
>
> example.com/bmw
> example.com/toyota
> example.com/nissan
> ..
> should invoke method (for example "view") in my controller with  
> parameter "bmw", "toyota" etc.
> Probably I should configure it in routes.php but I don't have idea  
> how.
>
> Regards,
>
> Marcin
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20061101/4fc2fde9/attachment.html>


More information about the talk mailing list