如何在cakephp 3.6.10中使用$ this-> autoRender = false? [英] How to use $this->autoRender = false in cakephp 3.6.10?
问题描述
我试图通过在pagesController中运行功能test()在屏幕上显示测试数据。用$ this-> autoRender = false代替它,但是它仍然给我错误:
I am trying to display the test data on the screen by running function test() in the pagesController. Used $this->autoRender = false for it, but it is still giving me error:
请帮帮我。我认为存在一些版本问题,但我无法解决。谢谢。
Please help me out. I think some version problem is there, but I can't figure it out. Thankyou.
推荐答案
默认情况下,Cakephp将Pages控制器的显示操作作为主页。显示功能管理页面和子页面本身,这就是为什么您会出错。您可以在 /config/routes.php
Cakephp by default takes Pages controller's display actions as a home page. display function manages pages and subpages itself that is why you are getting error. Either you can change your default home page in your /config/routes.php
$routes->connect('/', ['controller' => 'Pages', 'action' => 'index']);
OR
在其他控制器中定义您的测试操作。
define your test action in some other controller.
OR
删除来自显示操作的代码
Remove code from display action
class PagesController {
function display()
{
// default controller code here
// your custom code here
}
}
希望这会起作用。
这篇关于如何在cakephp 3.6.10中使用$ this-> autoRender = false?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!