I am using CakePHP 3.1, I am trying to create a route that works like this pseudo code
: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’)
And the category would control the theme which changes the styles, this i would add in my ArticlesController.php
Is this even possible? If checking if something exist is out of scope of routes, I wouldn't mind doing a check inList. As the category and subcategory would be a fixed amount.
Is this to complicated for routes? should i just do this in the ArticlesController.php under the view action? and just do
$routes->connect('/:slug', ['controller' => 'articles', 'action' => 'view']);