php – Ho do I change the base path of routes in CakePHP? – Education Career Blog

I’m using CakePHP to produce a Facebook application (though the problem is not Facebook specific). As usual, I’m struggling to get the reverse routing to work properly. Previously I’ve abandoned the routing functionality, but this time I’d really like to make it work.

The problem is basically that Cake produces URLs relative to the base of the host server, but we need URLs relative to the Facebook canvas page. So, when I type:

echo $html->link(__('New Question', true), array('action'=>'add'));

I want it to produce “http://apps.facebook.com/appname/admin/questions/add“, but it instead produces http://apps.facebook.com/foo/bar/appname/admin/questions/add”, where foo/bar is the path from my host root to the app directory.

Having poked around the files in the config folder, I didn’t see anything obvious. Any pointers?

,

Figure it out.

Just needed to add this line:

Configure::write('App.base', '/appname/');

I put it in my app’s bootstrap.php, but I don’t think it matters too much. I might even go back and add a few lines to detect whether it’s running natively or through Facebook…

Leave a Comment