Forum


Replies: 3   Views: 4538
Addtemplatevariable
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 nikkyb8  · 28-11-2013 - 09:10

Hello,

I try toreplacea variable in adocxcreated(withouttamplate)but I donot succeed...

Here is my code
;:



require_once 'docx/classes/CreateDocx.inc';



$docx = new CreateDocx();

$contenu = "<style>";

$contenu .= file_get_contents ('css/tinymce.css');



 // .table1 tr td { border:3px solid black; } .table1 { border-collapse:collapse; color:#6B506B; border:1px solid #2E638E; } </style> ";

$contenu .= " </style> ";



$customLayout = array(

                    'width' => '11906',

                    'height' => '16838',

                    'numberCols' => '1',

                    'orient' => 'portrait',

                    'code' => '9',

                    'marginTop' => '1017',

                    'marginRight' => '1001',

                    'marginBottom' => '1417',

                    'marginLeft' => '1001',

                    'marginHeader' => '308',

                    'marginFooter' => '708',

                    'gutter' => '0'      

                );

$docx->modifyPageLayout('custom', $customLayout);





 $contenu .= '<p>$ma_var$</p>';

   $docx->embedHTML($contenu);

    

   $docx->addTemplateVariable('ma_var', 'David Hume');

    

// echo $contenu;

$docx->createDocxAndDownload('/tmp/'.$_SESSION["pseudo"].'_'.$_SESSION["utilisateur_id"].'/'.time().'ee');



 



Could you help me ?


Posted by nikkyb8  · 28-11-2013 - 11:57

It's good forthat, Ithank youfound asolution


Posted by jorgelj  · 29-11-2013 - 07:46

Hello,



You must save the file and then open it as a template to do that replacement.



Regards.