cakephp Router::parseExtensions('ics') doesn't work properly
I'm trying to create an ical-file.
So I set Router::parseExtensions('ics')
in router.php
.
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 loo开发者_StackOverflow社区ks 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?
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 had Router::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...
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.
精彩评论