rsanchez / json

Output ExpressionEngine data in JSON format.
http://devot-ee.com/add-ons/json/
100 stars 236 forks source link

New Feature #3

Closed jnsandrew closed 13 years ago

jnsandrew commented 13 years ago

I've added the ability to output data to an external file, within the json:entries function. It was something I specifically wanted for an upcoming project but I think it could be useful for some other people.

In the json:entries tag, it accepts two new parameters:

Path to the file output="images/output.json"
- Path relative to the main index.php file, doesn't need a slash at the start,
- add filename and extension, so you can output to .txt, .php etc. if required
Cache the file refresh = "240"
- Number of seconds until the plugin refreshes the file

I've also updated the readme to include these new parameters.

rsanchez commented 13 years ago

Kind of an interesting feature. I'm curious what the application is, though. Why an external file instead of pulling directly from a url?

jnsandrew commented 13 years ago

rsanchez commented 13 years ago

Why not have the mobile app read directly from the plugin/url? Say you have placed the json plugin in a template called json/output, and then have your mobile app read from http://yoursite.com/json/output, rather than from a file?

jnsandrew commented 13 years ago

rsanchez commented 13 years ago

Yeah, if you add terminate="yes" to the plugin, it will output the application/json content type headers, so you shouldn't need a json extension. Also, if you find you do need a json extension, you can always name your template output.json (add the extension to your template name) and the url will mimic a json file http://yoursite.com/json/output.json

jnsandrew commented 13 years ago

Brilliant thanks!