我正在使用CakePHP 3.1,我正在尝试创建一个像这样工作的路由 伪代码
:category/:sub-category/:slug
if(:subcategory doesn’t exist){ treat as :controller/:action }
:category/:controller/:action
:category/:controller
if(:controller doesn’t exist){ treat as action }
:category/:action
if(:action doesn’t exist){ then action is view use as slug }
:category/:slug
if(:slug doesn’t exist){return 404 }
:category/:sub-category/
connect( controller=>article, action=>view, :subcategory, :slug=>’home’
:category/)
connect( controller=>article, action=>view, :subcategory=>none , :slug=>’home’)
该类别将控制更改样式的主题,我将在我的ArticlesController.php中添加
这甚至可能吗?如果检查某些东西是否存在超出路径范围,我不介意检查inList。由于类别和子类别是固定金额。
路线是否复杂?我应该在视图操作下的ArticlesController.php中执行此操作吗?而且只是做
$routes->connect('/:slug', ['controller' => 'articles', 'action' => 'view']);