I have a CakePHP 1.3 shell that requires the use of requestAction() to generate HTML from a separate controller. The URL for that call is generated using:
$url = Router::url(array('controller' => 'my_controller', 'action' => $action_str));
$data = array('url' => array('ext' => 'json'),
'return' => 'return',
'pass' => array('an_id_str' => $an_id));
$action_str, ‘an_id_str’, and $an_id are the only things in my code that change between calls, and requestAction() is called as such:
$this->requestAction($url, $data);
Note: since $action_str can change for each call, it generates the new $url for each individual requestAction() call.
The first time the requestAction() call is made, it works great. The second time I call requestAction(), it throws the following error:
"Error: Missing Controller 'c:\...\cake\console'"
Any ideas what might be causing the router to mess this up, and how I can fix it?
One note – this actually happens in a couple different shells that use similar functionality.
The correct fix for this issue is that in my $url array
I needed to add the ‘base’ key and set it to false as such:
From the docs at http://api13.cakephp.org/view_source/router#line-733 :
‘There are a few ‘special’ parameters that can change the final URL string that is generated
base– Set to false to remove the base path from the generated url. If your application is not in the root directory, this can be used to generate urls that are ‘cake relative’. cake relative urls are required when using requestAction.”‘