Forum


Replies: 3   Views: 3086
Createtemplate.returnallvariables is not returning all variables
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 mquadrat  · 14-09-2011 - 09:20

CreateTemplate.ReturnAllVariables in some cases does not return the correct set of variables included in the document. I changed the code to the following, which works for me:

Original code:
[code]
$documentSymbol = explode(self::$_templateSymbol, self::$_document);
$i = 0;
foreach ($documentSymbol as $documentSymbolValue) {
// avoid first and last values, and tag elements
if ($i == 0 || $i == count($documentSymbol)
|| $documentSymbolValue[0] == '<') {
$i++;
continue;
} else {
$variables['document'][] = strip_tags($documentSymbolValue);
$i++;
}
}
[/code]

My code:
[code]
$documentSymbol = explode(self::$_templateSymbol, strip_tags(self::$_document));
$i = 0;
foreach ($documentSymbol as $documentSymbolValue) {
if ($i % 2 == 0) {
$i++;
continue;
} else {
$variables['document'][] = strip_tags($documentSymbolValue);
$i++;
}
}
[/code]

In the case I faced the spellchecker added xml markup directly after the delimiter, so the if-case fired and the loop continued without adding the variable. I think there was a reason you wrote the code the way you did it. So am I missing something?