[英]CakePHP: How do you avoid the use of a template when rendering JSON?
I'm presently working with a new project in CakePHP, and when I add a json request to a controller, CakePHP looks for a matching view template in the views folder. 我目前正在使用CakePHP中的一个新项目,当我向控制器添加json请求时,CakePHP在views文件夹中寻找匹配的视图模板。 This behavior would be fine for regular pages, but every single one of my json view templates is completely empty . 对于常规页面,此行为会很好,但是我的json视图模板中的每个模板都完全为空 。 I use a "json" layout that looks like this: 我使用如下所示的“ json”布局:
<?php
Configure::write('debug', 0);
echo json_encode($json_output);
?>
I realize a partial solution might be to simply "touch" a file for every json view that I create, but that involves SSHing into the server and doing a lot of overhead stuff. 我意识到部分解决方案可能是为我创建的每个json视图简单地“触摸”一个文件,但这涉及到SSH进入服务器并做很多开销的工作。 Is there a way to simply tell CakePHP to use just the layout for a given view? 有没有一种方法可以简单地告诉CakePHP 仅使用给定视图的布局 ?
You can disable a view in cake. 您可以在蛋糕中禁用视图。
http://www.sethcardoza.com/posts/view/31/title/disabling-layouts-and-views-in-cakephp http://www.sethcardoza.com/posts/view/31/title/disabling-layouts-and-views-in-cakephp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.