开发者

Cakephp inflection, how to change a plural to a singular?

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?


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"


yes. go to www.yoursite.com/shop

look at the error message and follow the template

OR

in route.php. redirect shop to shops

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜