Forums / Developer / mofiying the header
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
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.
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.phpChanges here will override the global header information.