Sometimes Im get this kind of error when working with my plugins:
Class PluginNameAppController not found in ...
It's really weird because I connect plugin AppController before any controller using App::uses();
And this error occur randomly, then, I refresh current page (or clean tmp\cache\persistent) and it's gone.
I have 3 plugins connected in Config/bootstrap.php and I think they are conflicting some how.
Cakephp 2.6.0.
Use
Configure::write('Cache.viewPrefix', 'prefix');
with different value
in PluginAppController's beforeFilter function.
Ok, problem is still not resolved, but here is few solutions to resolve it:
Comment this lines in core.php: chopapp.com/#i5x18g0p
Uncomment Cache.disable in core.php: Configure::write('Cache.disable', true);
Related
I am developing an application in CakePHP 1.3. Everything is working fine but one error is there.
When I use redirect() in my .ctp page it gives error
Fatal error: Call to undefined method DebugView::redirect()
As redirect is working fine when I use it in controller.
I have included helpers as follows in my AppController
var $helpers = array('Html', 'Form','Session');
Please help
thanks in advance
You never redirect (or output any header if possible) in the view layer.
Use the controller to do so.
The view then should only render the output according to the desired output format (html, xml, json, ...). Header stuff is part of the reponse and responsibility of the controller (and in 2.x the response class itself).
So your observation that it will work with controllers and not inside views is correct.
"Call to undefined method" always is a good indicator for a method not being available in this scope.
Redirects being part of the "logic" makes them only available in controllers and components. Never ever in the view (output after all logic happened).
In your controller:
$this->redirect( 'url, absolute or relative here' );
Done.
Hi I want to add a new layout to my cakephp, but somehow the system keeps looking in the view folder from the controller instead of the /app/View/Layouts folder.
Error: The view for TestsController::desktop() was not found.
Error: Confirm you have created the file: /app/View/Tests/desktop.ctp
the desktop.ctp file is in /app/View/Layouts. The same place as the default.ctp
The code in the controller is:
public function desktop() {
$this->layout = 'desktop';
}
What is wrong here? I don't understand why cakephp keeps looking in the view/controller-name folder... I need this fixed because I want to use this layout for other controllers. Thanks.
If you read the message carefully, you'll see cake is telling you it cannot find your view, not your layout.
So, create an empty /app/View/Tests/desktop.ctp and see what happens. I'm hoping magic.. :)
I was setting up this application in cakephp.I have homes controller which works well and then i have chokates controller which has an index action.But whenever i run this chokates controller i get an error
Call to a member function charset() on a non-object
I had a print of $this in top of this controller which shows me that html and javascript helpers are loaded already.Then why i get this error i dont know.
Please help
Here is the link http://www.maninactionscript.com/chokate
go to the chocolates link.
Regards
Himanshu Sharma
Well, looking at your error message it appears that a couple things are happening here that should be fixed:
The view for ChokateController::index() was not found.
Ensure that you have an index.ctp file in /app/views/chokate/.
The HtmlHelper object likely isn't being added to the view because you have a manually configured list of $helpers. If you have assigned an array to $helpers in ChokateController ensure that Html is listed.
I have one problem with CakePHP and $requestAction. In the 1.3 manual of cakephp there is written
It is important to note that making a requestAction using 'return' from a controller method can cause script and css tags to not work correctly.
Now I got this case. The contents of $html->css() and $html->script() are not displayed in the final view after using a $this->requestAction() in combination with return in the controller.
Does anybody know a workaround for this problem? How to use styles and scripts together with $this->requestAction(<...>, array('return'))?
I have problem when I want to use $javascript->link('prototype') in the default.ctp layout. It returns:
Undefined variable: javascript [APP\views\layouts\default.ctp, line 6]
I also added this code into app_controller.php:
<?
class AppController extends Controller {
var $Helpers = array('Html','Javascript','Ajax','Form');
}
?>
The file prototype.js is already in webroot/js folder.
Where is the problem?
I have had this problem many times. It's usually either caused by the controller code being overwritten somewhere or some weirdness happening with Cake's automagic stuff. If you remove all of your helpers and then add them one by one it will probably work eventually.
Another perfectly valid way of generating JavaScript links is by using the following which doesn't access the $javascript variable:
echo $html->script(array('prototype'));
It has to be $helpers instead of $Helpers.
You just open the error console of the Firefox browser (shortcut key ctrl+shift+j).
Find the error and click on it.
After clicking, you will see the head portion.
Note the location of the JavaScript file (*.js) which you want to locate (you will see the location is not correct).
Cut the JavaScript file from webroot and paste it in given location of head block.
Example:
This will show on error console. Map_demo is my project, and in its place your project name will display:
<script type="text/javascript" src="/map_demo/js/test.js"></script>
Cut the JavaScript file from webroot
Make the JavaScript folder in your project application folder, /map_demo/js
Paste test.js (your script file) here
Now your JavaScript function will work.
Just in case somebody else comes across this bug/issue: it was also happening to me, until I commented out the line $session->flash(); in my default layout. Realising that the error was being caused by flash messages, I went back to the controller and noticed that I was using separate layouts for flash messages (e.g. 'message_alert') and that those layouts didn't actually exist in the view folder!
So remember, errors like this could mean that a file is not defined yet. Best of luck.