How can I export data from a CakePHP 2.4 app as KML, not just XML and JSON?
This is what I've been trying:
1: I created a simple controller action, download
, to find all data in my model:
$this->set('posts', $this->Post->find('all'));
2: I addeded the file type in routes.php
:
Router::parseExtensions('json', 'xml', 'kml', 'csv');
3: I created a folder for my data view file type:
/app/View/Post/kml
4: I created a view, download.ctp
, which manually echos out the XML tags for the KML file.
Now comes the problem: When I place this view file under /app/View/Post/xml
, visiting /posts/download.xml creates a valid KML document I can open in Google Earth, albeit with an .XML extension. When I place the file under /app/View/Post/kml
, and visit /posts/download.kml, it throws an error: View file "/home/public/app/View/Themed/Cakestrap/Posts/download.ctp" is missing.
I tried copying my view to the above location, but that just echos the XML into my standard layout. What's the proper way to create data views for filetypes other than XML and JSON?