ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Downloading an XML template as an XML File

November 13, 2012 12:35pm

Subscribe [1]
  • #1 / Nov 13, 2012 12:35pm

    Aaren Hofferth

    55 posts

    I have a template within EE that is set to the XML type. I’m wondering if instead of rendering the page in the browser, if it can be downloaded as an XML file instead. I’ve seen solutions within PHP that force the browser to download a file, but this assumes the file has an actual extension, which EE does not have. (e.g, “filename.xml” vs ee’s structure “/filename”).

    Any ideas on where to begin with this? Thanks.

  • #2 / Nov 13, 2012 12:46pm

    Aaren Hofferth

    55 posts

    Apparently all that need to be added—since EE is already sending the proper XML headers—is to tell the template to force the download via a PHP header:

    <?php header('Content-Disposition: attachment; filename="foodbanks.xml"'); ?>

    This seemed to work.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases