mofiying the header

Author Message

johann savalle

Saturday 09 July 2005 8:34:46 pm

Hello,

I need to change the header of a template, in php it would be done like this:

header("Content-Type: application/msword");
header('Content-Disposition: attachment; filename="filename.doc"'); 

but using php in a template is problematic.
(afaik, it requires kernel hacking... unless recent update non-documented)

Is there a simple way of doing that with eZ ?
any idea is welcome.

johann

johann savalle

Sunday 10 July 2005 10:21:55 pm

feel free to answer...

the first three answers will get an invitation to a wonderfull trip to the wild south of east asia, great activities : visit of the death canyon, partying with a local tribe of cannibals...

hurry up ! not many places left...

Pål J Didriksen

Monday 11 July 2005 4:03:45 am

Not sure if I understand exactly what you want to do, but you can send variables to templates from php, like this:

$tpl->setVariable( 'MyVariableName', $MyValue );

To be able to use the template-functions, you should probably also include this: (I'm not too experienced in this field, so please excuse me if I'm wrong, or leave something out...)

include_once( "kernel/common/template.php" );
$tpl =& templateInit();

$result = array();
$result['content'] =& $tpl->fetch( "design:MyTemplate.tpl" );
$result['path'] = array( array( 'url' => false,
                                'text' => ezi18n( 'design/standard/MyModule', 'MyModule' ) ) );

Then you should be able to use your variable by simply inserting <b>{$MyVariableName}</b> in your template.

johann savalle

Monday 11 July 2005 6:00:55 am

yes, this okay, but a template is an html file in ez, and there is no way I can change the filetype header from html to word.
Usually this is possible when programming in php, but even if I put some php code like the one above, it will not work since ez send his file header first.

So I was wondering if there is any chance to do that with any eZ function that would be hidden or unknow...

K259

Monday 11 July 2005 6:30:43 am

Check out:

/lib/ezutils/classes/ezmimetype.php

You can also change:
kernel/content/view.php
Changes here will override the global header information.

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 19 2025 00:12:53
Script start
Timing: Jan 19 2025 00:12:53
Module start 'layout'
Timing: Jan 19 2025 00:12:53
Module start 'content'
Timing: Jan 19 2025 00:12:54
Module end 'content'
Timing: Jan 19 2025 00:12:54
Script end

Main resources:

Total runtime0.6519 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.0054 587.8125152.6094
Module start 'layout' 0.00540.0023 740.421939.4141
Module start 'content' 0.00770.6427 779.8359564.8359
Module end 'content' 0.65040.0015 1,344.671912.1875
Script end 0.6518  1,356.8594 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00290.4442160.0002
Check MTime0.00130.1956160.0001
Mysql Total
Database connection0.00070.105110.0007
Mysqli_queries0.599491.9562650.0092
Looping result0.00060.0853630.0000
Template Total0.625595.920.3127
Template load0.00190.293220.0010
Template processing0.623595.654820.3118
Template load and register function0.00020.029810.0002
states
state_id_array0.00110.176410.0011
state_identifier_array0.00070.106920.0003
Override
Cache load0.00160.2525320.0001
Sytem overhead
Fetch class attribute can translate value0.00090.144530.0003
Fetch class attribute name0.00120.177860.0002
XML
Image XML parsing0.00090.141130.0003
class_abstraction
Instantiating content class attribute0.00000.001760.0000
General
dbfile0.00080.1225160.0000
String conversion0.00000.001040.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
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs