Tuesday, November 27, 2012

Routes are confusing me

I'm working on the routes of my CakePHP site. The 'easy' ones I have already set like:
Router::connect('/contact', array('controller' => 'contacts', 'action' => 'index')); 
These are working.

But now I am confused as to how to continue with the more complex routing. For example, my url now is /findproducts/compare/1, where he goes to the controller findproducts and the action compare and 1 is the category_id. I have converted this with my routes to /vinden/vergelijk/1 (dutch translations). How do I get the 1 to swap with the category name? So that you don't get /vinden/vergelijken/1 but /vinden/vergelijken/food for example. Do I have to change all my html links for that? So that my controller doens't have  the action "public function compare($id = null)" but "public function compare($categoryname = null)"? I hope not, because that would be a lot of work..

Another question, in some controllers I work with $this->params, if I change my routing, will this effect my passed params? Because sometimes I need these params, but I rather not have my visitors see them. I don't know if that is possible.

I hope you understand what I want to do. I have read a lot about it (on the CakePHP website, this group, etc.) but I'm a little bit confused about how to do it. That's why I came here :)

--
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: