views:

165

answers:

1

I'm trying to build a mini cms, whereby all urls go to the index action of a 'products' controller.

The products_controller checks the url and treats it as a parameter, so '/widgets' would hit the index($url) function and pass 'widgets' to be the $url param.

I then do a lookup like this checking a field called url:

$product= $this->Product->find('first', array('conditions' => array('Product.url LIKE' => $url)));

I then spit this $product out to my view. This method means I can add a product in my database, and specify the url for the product, without having to add stuff to routes. I also have a navbar which is simply made up of all the urls in the database, using a find all.

My problem is my routing and my admin. Because I'm routing ALL urls to the index() of the products_controller, its causing no end of problems with my admin section. I've put my admin in a seperate controller because of this, and manually connected the urls to the actions (index,view,edit,add,delete). The thing is my admin section doesnt work as the urls are being routed incorrectly, and its breaking the admin routing.

Can anyone see a way of having a 'catch all' route like that, and ALSO have my admin routing working.

Hope I've explained this clearly enough, if not please shout as I'd like to figure this one out.

+1  A: 

If you have a route that is overriding your default admin routes, you add something something like this in the routes.php to override that.

    Router::connect('/admin/:controller/:action/*',
                   array('admin'=>true));
bucho
Perfection, thanks :)
Pickledegg