I have a template with footers on page 2 and thereafter. None on page one.
When I replace variables in footer it inserts a footer on page 1. This is a problem.
How do I fix this?
I have a template with footers on page 2 and thereafter. None on page one.
When I replace variables in footer it inserts a footer on page 1. This is a problem.
How do I fix this?
Hello,
What license and version of phpdocx are you using? Your username doesn't have any license tied.
About your question, phpdocx template methods don't change/add contents unless it's requested.
Please send to contact[at]phpdocx.com the username or email of the user that purchased the license you are using, and the most simple script (and template) that illustrates your issue so we can check it.
Regards.
Hello,
We never request posting the license information in the forum.
As requested in our previous reply:
Please send to contact[at]phpdocx.com the username or email of the user that purchased the license you are using, and the most simple script (and template) that illustrates your issue so we can check it.
Regards.
The footer acts appropriately, until adding a header
$textHeaderOptions = array('fontSize' => 14,'b' => 'on','color' => COLOR_PAGE_HDR,);
$headerAssessment = new WordFragment($docx, 'defaultHeader');
$headerAssessment->addText('APPLICATION ASSESSMENT', $textHeaderOptions);
$valuesHeaderAssessment = array(array(array('value' =>$headerAssessment, 'vAlign' => 'center',), ),);
$tableProperties = array('border' => 'nil',
'tableAlign' => 'left',
'tableLayout' => 'fixed',
'tableWidth' => array('type' => 'dxa', 'value' => 10100),
'columnWidths' => array(10100,), // in twips
);
$headerAssessmentTable = new WordFragment($docx, 'defaultHeader');
$headerAssessmentTable->addTable($valuesHeaderAssessment, $tableProperties);
$docx->addHeader(array('default' => $headerAssessment));
Hello,
The code you have posted is not using any template method nor replacing any variable in the footer, it adds a header.
Adding headers do not remove/change footers, only existing headers are replaced. We have done some quick tests and everything is working correctly when adding headers/footers and also when replacing placeholders in them.
If you need to work with headers/footers per section, please check the documentation available on https://www.phpdocx.com/documentation/cookbook/headers-and-footers-for-sections.
For further support:
Please send to contact[at]phpdocx.com the username or email of the user that purchased the license you are using, and the most simple script (and template) that illustrates your issue so we can check it.
Regards.
I have now sent the entire code. Please not the subject of the email. I have sent the template in prior email.
The sending email address of the email is how I was originally registered, but I cannot reset my password.
Original username was rwp40
Hello,
addHeader and addFooter methods remove existing headers and footers. These methods are available to be used when creating a DOCX from scratch, not with templates, because existing headers/footers are removed, and the new headers/footers are added only to the last section.
To add contents to headers/footers to a DOCX template you can use the following methods:
Regards.
I would like to keep the footers from the template, but not add one to page 1 which the template does not have. The template has footers from page 2 onward. I do want to add headers starting on page 4+ but not change the footers in the process, which it seems to do.
Are headers and footers tied together so that adding one changes the other?
Dear Rick,
Headers and footers have some common tags, so changing one may affect others.
Your template includes footers in the first DOCX, but they are hidden because the template uses <w:titlePg/> tag (tag shared by headers and footers) that hides the footer.
Please follow the approaches detailed in our previous email, there's no other way to change headers or footers in templates in the current release of phpdocx. The importHeadersAndFooters approachs work perfectly for your case.
Regards