Forum


Replies: 4   Views: 3998
Replace variables in header not working
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by brieflogic  · 08-08-2011 - 01:24

Hello, I'm trying to replace a few tokens in the header and footer... these are noted in the docx template file with preceeding and concluding '$'.... i.e. $BRIEFTITLE$, and so on.

Here is the code:

[code]
$docx = new CreateDocx();

$settings = array(
'header' => true
);

$docx->addTemplate('templates/bl_bluebrieftemplate.docx');
$docx->setTemplateSymbol('$');
$docx->addTemplateVariable('BRIEFTITLE', 'Testing Brief ' . date("H:i:s"),$settings);
$docx->addTemplateVariable('BRIEFTEMPLATE', 'dock trial of template use '. date("H:i:s"),$settings);
$docx->addTemplateVariable('BRIEFCONTENT', 'Body Content '. date("H:i:s"),$settings);
$docx->addTemplateVariable('BRIEFFOOTER', 'Footer Content ' . date("H:i:s"),$settings);
$docx->addTemplateVariable('BRIEFACCOUNT', 'Account Name '. date("H:i:s"),$settings);
$docx->addTemplateImage('BRIEFLOGO', 'path/to/file.gif',$settings);
$docx->createDocx('outputs/bluebrief_'.date("H_i_s"));
[/code]

the file renderes, and only briefcontent variable is replaced. The others are not... any ideas?