Forums / Developer / Content-Disposition for my template?

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

eZ debug

Timing: Jan 17 2025 23:45:26
Script start
Timing: Jan 17 2025 23:45:26
Module start 'content'
Timing: Jan 17 2025 23:45:26
Module end 'content'
Timing: Jan 17 2025 23:45:26
Script end

Main resources:

Total runtime0.7037 sec
Peak memory usage4,096.0000 KB
Database Queries202

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.8672180.8359
Module start 'content' 0.00540.6014 769.7031613.0078
Module end 'content' 0.60680.0968 1,382.7109337.3672
Script end 0.7037  1,720.0781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.5516210.0002
Check MTime0.00140.1940210.0001
Mysql Total
Database connection0.00080.111010.0008
Mysqli_queries0.640090.94902020.0032
Looping result0.00160.22292000.0000
Template Total0.680996.820.3405
Template load0.00200.286120.0010
Template processing0.678996.473920.3395
Template load and register function0.00020.023410.0002
states
state_id_array0.00080.114010.0008
state_identifier_array0.00080.108020.0004
Override
Cache load0.00170.2432240.0001
Sytem overhead
Fetch class attribute can translate value0.00130.188940.0003
Fetch class attribute name0.00110.153470.0002
XML
Image XML parsing0.00140.195140.0003
class_abstraction
Instantiating content class attribute0.00000.002580.0000
General
dbfile0.00150.2169360.0000
String conversion0.00000.001030.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 8

Time used to render debug report: 0.0002 secs