Forum


Replies: 1   Views: 2553
How do i use replacevariablebytext in header with firstmatch option
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 kelthalorn  · 07-11-2017 - 16:09

Hi,

We use Premium version and encounter some issue.

We have a template file with variables in header. We use replaceVariableByText with target on "header". But, we try to only set the first page instance of a variable and not on all pages. We try to add "firstMatch" true but it doesn't work.

Did we make something wrong or is this option restricted for document target (it works for this one). Have you got any idea to make this possible.

Here is log we get by dumping value during process :

  • This one with document target and a variable with 2 instance in template:
string(50) "//w:t[text()[contains(., "$prenomNomDiffuseur$")]]"
bool(false)
array(2) {
  [0]=>
  object(SimpleXMLElement)#343 (1) {
    [0]=>
    string(20) "$prenomNomDiffuseur$"
  }
  [1]=>
  object(SimpleXMLElement)#560 (1) {
    [0]=>
    string(20) "$prenomNomDiffuseur$"
  }
}
  • Now with header target and a variable instanciate:
string(47) "//w:t[text()[contains(., "$headerNomAgence$")]]"
bool(false)
array(1) {
  [0]=>
  object(SimpleXMLElement)#347 (1) {
    [0]=>
    string(17) "$headerNomAgence$"
  }
}

Thanks for your time and help