CakePHP:路由和静态页面

CakePHP:路由和静态页面,cakephp,routing,Cakephp,Routing,我正在做一个小项目——网站。有画廊,用户登录,商店和许多小文本部分-有图像和没有。 我想创建漂亮的URL,例如: Gallery -> /eng/gallery (GalleryController::index) Gallery album /eng/gallery/album_name_slug (GalleryController::view) Shop -> /eng/products (ProductsController::index) Shop one product

我正在做一个小项目——网站。有画廊,用户登录,商店和许多小文本部分-有图像和没有。 我想创建漂亮的URL,例如:

Gallery -> /eng/gallery (GalleryController::index)
Gallery album /eng/gallery/album_name_slug (GalleryController::view)
Shop -> /eng/products (ProductsController::index)
Shop one product -> /eng/products/product_name_slug (ProductsController::view)
所有其他文本页都转到PagesController,但不带/pages/view前缀

Contacts -> /eng/contacts
About us -> /eng/about_us
我想我可以做这样的东西:

// Homepage
Router::connect('/', array('controller' => 'homepage', 'action' => 'display'));

/* There delegate routes for each controller/method (gallery, shop, etc) */

// All what is not in thease controllers/methods goes to pagescontroller
Router::connect('/*', array('controller' => 'pages', 'action' => 'view'));
在routes.php中实现它的最佳方法是什么?也许你可以举一些一般的例子

谢谢

对于Gallery->/eng/Gallery GalleryController::index:

Router::connect('/eng/gallery', 
    array('controller' => 'gallery', 'action' => 'index'));
对于Gallery album/eng/Gallery/album_name_slug GalleryController::view:

Router::connect('/eng/gallery/:album', 
    array('controller' => 'gallery', 'action' => 'view'), 
    array('pass' => array('album'),'album' => '[0-9a-zA-Z]+') 
); 

对Products controller重复此操作

不可能将控制器和方法用作默认值,只有在没有此类控制器/方法时才能转到控制器页面?我在找干溶液。当然如果没有,我会接受你的回答!我的catchall由以下内容组成:路由器::连接“/*”,数组“控制器”=>“页面”,“操作”=>“显示”;我看你的路线没有问题。什么不起作用?我想知道有没有可能,让它起作用,不授权所有功能性产品/画廊路线,只授权所有功能性路线?你说的授权所有功能性路线是什么意思?嗯。。。我的问题提得很糟。无论如何,谢谢!