views:

219

answers:

2

Hi,

I have a controller called "Shops", this is the way the routing system looks for it, however I want to be able to called this controller and what not 'shop'.

Is it possible to do this.

Cheers!

A: 

yes. go to www.yoursite.com/shop

look at the error message and follow the template

OR

in route.php. redirect shop to shops

Funky Dude
+2  A: 

It sounds like you are just trying to just change the URL from example.com/shops to example.com/shop ... is this correct? If so edit app/config/routes.php to include the following line:

Router::connect('/shop/*', array('controller' => 'shops'));


Note: The above solution is probably what you are looking for, however if you intended to make CakePHP never pluralise 'shop' to 'shops' then the following is how you do that:

You'd edit app/config/inflections.php and modify the $uninflectedPlural array to include 'shop'.

For example:

$uninflectedPlural = array('shop');

From then on your controller will be: app/controllers/shop_controller.php with "class ShopController extends AppController"

And your model will stay as per usual with app/models/shop.php with "class Shop extends AppModel"

Hopefully the above helps you.

Benjamin Pearson
+1 Routes are certainly the way to go. You don't want to work against Cake's inflections unless you have a really good reason to.
deceze
I already had the routing but I didn't like having a 'shops' controller and 'shops' views folder. Looking for something like the equivalent of a single resource in rails. The uninflectedPlural did the trick, don't worry I'll use it sparingly.
Smickie