I’m trying to set dynamic routes for small CMS. Is there proper way how to do it? I founded somewhere this soliution, but honestly I’m not satisfied with it. CMS have other content types so define this for every model does’t seem right to me.
$productsModel = ClassRegistry::init('Product');
$products = $productsModel->find('all');
foreach($products as $product){
Router::connect('/produkty/:id/'.$product['Product']['url'], array('controller' => 'products', 'action' => 'view',$product['Product']['id']));
}
Thanks for any help!
No need to do anything complex 🙂
In routes.php:
In products_controller.php: