Hi,
it’s really nice article. I found it useful. Thanks.

Best regards,
karmy

karmy on 2/1/12

Mark, can you confirm that importing a model inside a custom route class works in 2.x? I’m getting:

Fatal error: Class ‘Model’ not found in /var/www/vhosts/jcah/app/Model/AppModel.php on line 3

By echoing each className inside of App::load() I can see that Model has not yet been loaded. Is this something that changed in 2.x? There seems to be many things that the migration guide doesn’t mention at all, or very little.

brian on 2/20/12

Hahah.. This is exactly what I’m looking for! Thank you, sir.. If only I found this post earlier :3

thom on 4/14/12

Very helpfull for mr thanks a lot..

Pankaj on 6/26/12

Hello sir,

Great article.

Please give us google+ option, so we can give +1 for your great topics and great effots.

Thanks & Regards
Chetan Patel
chetanspeed511987@gmail.com
chetan4cake.blogspot.in

Chetan Patel on 9/26/12

is there possible to use custom routing like this?:

url/slug => controller => x & action =>y
url/slug1/slug2 => controller => x action => z
and more

Vahid on 10/26/12

Brian: It should work, but you’ll have to make sure all the dependencies up to the Model class are imported correctly using App::uses().

Vahid: Of course that’s totally possible. You could have one route with /url/:slug and the other with /url/:slug/:slug_two which should match to different controllers.

mark story on 10/30/12

I’ve created new plugin in Cakephp Croogo. It’s named “doanhnghiep”. And i get a link “/doanhnghiep/doanhnghiep/edit/[id]” when i want call edit function. So, i want to custom to new link “/doanhnghiep/edit/[id]”. How i can do this?

Condomvang on 12/3/12

Hi,

I am facing an issue here..

$params = parent::parse($url);

$params retruns empty always but $url have value..
But is the issue.. can you please help me !!!

harry on 5/17/13

Fantastic goods from you, man. I have understand your stuff previous to and you are just too great.
I really like what you’ve acquired here, certainly like what you are saying and the way in which you say it. You make it enjoyable and you still take care of to keep it wise. I cant wait to read much more from you. This is actually a great website.

garcinia cambogia for weight loss on 8/4/13

This post has been really helpful. I’ve created custom Route class that works perfectly when I set it using array(‘routeClass’ => ‘MyCustomRoute’));

My trouble is trying to set the defaultRouterClass with the following at the top of routes.php:

App::uses(‘MyCustomRoute’, ‘Routing/Route’);
Router::defaultRouteClass(‘MyCustomRoute’);

The class is loaded properly, but now the parent::parse(url) returns false;

Thanks for any insight you may have.

Reed on 9/17/13

Great Article.

I am using cakePHP2.3 & using
Router::connect(’/:slug’, array(), array(‘routeClass’ => ‘SlugRoute’));

now from database i am fetching associating Plugin, Controller, Action & Params if any & return it using an array. but its giving me out of memory error.

Plese let me know if i am doing some wrong

also it will help full if i can route URL something like Joomla [Menu/Submenu/Submenu/Submenu…] & then it will check in db & get request URL from DB

also if i am able to route hidden menus like /gallery move me to all gallery category page & then how i can route individual category as it is not in menu managemnt

Sandeep on 1/8/14

Hi Mark,
I hope you doing well.
One quick question can you please let me know how we can handle Route with slug and static string i.e.

Router::connect(’/:slug-domainname/:id’, array(‘controller’ => ‘test’, ‘action’ => ‘details’), array(‘pass’ => array(‘slug’, ‘id’) )
);

in above example “:/slug” is dynamic but “-domainname” is hardcoded string in routes file. can you please let me know how we can handle this.

i know we can handle this using Route Class but without RouteClass is it possible ?

Thank You in Advance.
Vinod

Vinod Patidar on 1/17/14

Vinod Patidar: I’m pretty sure you need to use route class for that, or move the static -domainname somewhere else in the URL.

mark story on 1/19/14