I've been trying to figure out a route challenge.
I have the following routes which work fine:
Router::connect('/category/*', array('controller' => 'categories', 'action' => 'index', 'category'));
Router::connect('/subcategory/*', array('controller' => 'categories', 'action' => 'index', 'subcategory'));
As you can see, they pass a param of either 'category' or 'subcategory', this is used in the categories controller to change which model it searches from.
However, the URL treatment is formatted as such with these routes: /sitename/subcategory/bananas/
I would ideally like to access a subcategory as follows via the url (you've probably guessed by now): sitename/category/food/bananas
I've tried a lot of route variations with no luck. I think this is as close as I've got:
//this doesn't seem to fail but returns nothing
Router::connect(
'/category/:category/:sub_category',
array('controller'=>'categories','action'=>'index', 'subcategory')
);
//this works fine for categories
Router::connect( '/category/*', array('controller'=>'categories','action'=>'index', 'category'));
Thanks for your time!
-Cybo
-- Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment