Ho do I change the base path of routes in CakePHP?

依然范特西╮ 提交于 2019-12-06 15:00:29

问题


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?


回答1:


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...



来源:https://stackoverflow.com/questions/719486/ho-do-i-change-the-base-path-of-routes-in-cakephp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!