我正在开发一个小项目 - 网站。有画廊,用户登录,商店和许多小文本部分 - 图像和没有。 我想制作漂亮的网址:
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中创建它的最佳方法是什么?也许你可以给出一些通用的例子?
谢谢!
答案 0 :(得分:0)
对于图库 - > /eng/gallery
(GalleryController :: index):
Router::connect('/eng/gallery',
array('controller' => 'gallery', 'action' => 'index'));
对于图库专辑/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]+')
);
重复产品控制器