We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9575
    • 19 Posts
    Hi,

    I’ve been scouring the forums and API documentation to see if I could find an answer to this but I haven’t so thought I’d ask.

    I have a page which contains nothing but a snippet call, the snippet produces a CSV export of data unique to the logged in user (not authenticated via modx, it’s our own back end). I would like to change the filename of the file produced but I am guessing that despite sending headers (using the PHP header command) they don’t seem to work, is this because modx is overwriting/re-issuing the content-disposition header with the alias of the document?

    Is there any API functions (or other method) of setting the HTTP headers from a snippet??

    Thanks

    Simon
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: felikz at Jun 17, 2009, 04:46 AM

      I would like to change the filename of the file produced but I am guessing that despite sending headers (using the PHP header command) they don’t seem to work, is this because modx is overwriting/re-issuing the content-disposition header with the alias of the document?
      You can have the snippet simply echo the output and then exit() to prevent further processing by MODx. Just make sure you deal with the output buffer (i.e. ob_end_clean() or something) and set all the appropriate headers if you do it that way.
        • 9575
        • 19 Posts
        Worked perfectly, thanks. Although I had to use ob_end_flush() to stop my echo being discarded.