Content-Disposition for my template?

Author Message

Ivan Švogor

Thursday 26 May 2011 6:28:00 am

Hi!

I am trying to create a downloadable file that is autogenerated. Like rss, when you use custom layout. You create a layout.ini config and you get a nice output of whatever you want (RSS, iCal format or whatever). I would like to download this. If I'm using .php file, you simply set Content-Disposition header echo out whatever content, and user can download it. Is there a similar way to do this in ezPublish?

(I've tried out custom headers, but it is not ment for this purpose, or I don't understand it - can some one clarify?)

tnx

Steven E. Bailey

Thursday 26 May 2011 9:18:05 am

This is trivial if you get the content through an extension - I've done many to output xml,vcards etc... but, I don't think you can change the content disposition from a template.  It's always AFAIR coming from php.

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Marko Žmak

Thursday 26 May 2011 9:25:45 am

If you don't want to make an extension you could use the wrap operator:

  • http://projects.ez.no/wrap_operator

to execute the header() PHP function.

P.S. I would advise you caution when using the wrap operator, and not to get carried away with it.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Ivan Švogor

Thursday 26 May 2011 2:21:07 pm

How about go into index.php, and intercept the echo that writes out the page. Search for my custom tag, in my template e.g. <downloadable/> and if i find this, printout disposition header, and if not, carry on with page? - how bad is this quick fix on performance? (I did it, as a temporary solution, I will tryout wrap_operator)

Marko Žmak

Thursday 26 May 2011 3:05:25 pm

"

How about go into index.php, and intercept the echo that writes out the page. Search for my custom tag, in my template e.g. <downloadable/> and if i find this, printout disposition header, and if not, carry on with page? - how bad is this quick fix on performance? (I did it, as a temporary solution, I will tryout wrap_operator)

"

It's not only performance issue, but the fact you are hacking the files of eZP installation. It's not really a clean way and you'll have to watch out for upgrades...

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:52:09
Script start
Timing: Jan 18 2025 02:52:09
Module start 'layout'
Timing: Jan 18 2025 02:52:09
Module start 'content'
Timing: Jan 18 2025 02:52:11
Module end 'content'
Timing: Jan 18 2025 02:52:11
Script end

Main resources:

Total runtime1.3145 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 587.9375152.6250
Module start 'layout' 0.00490.0024 740.562539.4531
Module start 'content' 0.00731.3056 780.0156607.9297
Module end 'content' 1.31290.0015 1,387.945316.1563
Script end 1.3144  1,404.1016 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2437160.0002
Check MTime0.00130.1012160.0001
Mysql Total
Database connection0.00060.045310.0006
Mysqli_queries1.260895.9159650.0194
Looping result0.00070.0500630.0000
Template Total1.285897.820.6429
Template load0.00210.157520.0010
Template processing1.283797.659720.6419
Template load and register function0.00030.021110.0003
states
state_id_array0.00140.110210.0014
state_identifier_array0.00150.111720.0007
Override
Cache load0.00160.1250240.0001
Sytem overhead
Fetch class attribute can translate value0.00060.048230.0002
Fetch class attribute name0.00140.109870.0002
XML
Image XML parsing0.00130.102630.0004
class_abstraction
Instantiating content class attribute0.00000.001280.0000
General
dbfile0.00100.0776250.0000
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs