cakephp Router::parseExtensions('ics') 无法正常工作
我正在尝试创建一个 ical 文件。
所以我在 router.php
中设置了 Router::parseExtensions('ics')
。
我在 app/views/layouts
中创建了一个文件夹 ics
,并创建了一个包含此内容的 default.ctp
<?php
header('Content-Type: text/calendar');
echo $content_for_layout;
?>
在我的reservationsController中,我创建了一个 ical ()
操作并在 /app/views/reservations/ics/
中创建了 ical.ctp
。
因此,如果我尝试访问 http://localhost/reservations/ical/1.ics
我收到错误:
Error: The view for ReservationsController::ical() was not found.
Error: Confirm you have created the file: C:\xampp\htdocs\ers\app\views\reservations\ical.ctp
所以我对错误消息有点困惑。为什么它在 app\views\reservations\
中搜索 ical.ctp
,而不是在 app\views\reservations\ics\
中搜索?
当我使用其他扩展(如 .xml
)时,错误消息如下所示:
Error: Confirm you have created the file: C:\xampp\htdocs\ers\app\views\reservations\xml\ical.ctp
Why does xml work and ics don't?出了什么问题?
I'm trying to create an ical-file.
So I set Router::parseExtensions('ics')
in router.php
.
I created a folder ics
in app/views/layouts
and a default.ctp
with this content
<?php
header('Content-Type: text/calendar');
echo $content_for_layout;
?>
In my reservationsController I created a ical()
action and created a ical.ctp
in /app/views/reservations/ics/
.
So, if I'm trying to access http://localhost/reservations/ical/1.ics
I get an error:
Error: The view for ReservationsController::ical() was not found.
Error: Confirm you have created the file: C:\xampp\htdocs\ers\app\views\reservations\ical.ctp
So I'm a bit confused about the error-message. Why does it search the ical.ctp
in app\views\reservations\
and not in app\views\reservations\ics\
?
When I'm using another extension like .xml
the error message looks like this:
Error: Confirm you have created the file: C:\xampp\htdocs\ers\app\views\reservations\xml\ical.ctp
Why does xml work and ics don't? What went wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我自己刚刚处理完这个情况。我一直在尝试显示
csv
扩展名,并且还收到“缺少视图”错误。一切都已就位;我设置了
/app/views/layouts/csv/default.ctp
和/app/views/users/csv/export.ctp
视图文件。我的/app/config/routes.php
文件顶部有Router::parseExtensions('csv');
。事实证明,我忘记了将 RequestHandler 组件添加到控制器的组件数组中:
var $components = array('RequestHandler');
。一旦我这样做了,一切就完美了。
因此,如果您因为遇到同样的问题而偶然发现了这个问题,请检查以确保您加载的 RequestHandler 组件可以为您修复问题...
I've just finished dealing with this situation myself. I'd been trying to get a
csv
extension to display, and I was also getting the "missing view" error.Everything was in place; I had my
/app/views/layouts/csv/default.ctp
and/app/views/users/csv/export.ctp
view files set up. I hadRouter::parseExtensions('csv');
at the top of my/app/config/routes.php
file.Turns out, what I had forgotten was to add the RequestHandler component to my controller's components array:
var $components = array('RequestHandler');
.Once I did that everything worked perfectly.
So if you've stumbled upon this question because you're having the same issue, check to be sure you're loading the RequestHandler component fixes things for you...
我在创建 ics 示例时遇到了同样的问题@ http://www.dereuromark.de/2011/11/21/serving-views-as-files-in-cake2
需要很长时间才能弄清楚这似乎是一个蛋糕错误并开了一张票为了它:)
http ://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/2565-cakeresponse-is-missing-icalendar-and-not-responding-as-documented
希望这个问题能尽快得到解决。
PS:我还为此发布了一个解决方法/快速修复,直到它在核心中得到修复。
I just had the same trouble creating the ics example @ http://www.dereuromark.de/2011/11/21/serving-views-as-files-in-cake2
Needed quite a while to figur out that this seems to be a cake bug and opend a ticket for it :)
http://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/2565-cakeresponse-is-missing-icalendar-and-not-responding-as-documented
Hopefully this will be resolved soon.
PS: I also posted a workaround / quickfix for this until it is fixed in the core.