When I run the following TBS template (.docx) the single quotes (') still remain on the final docx output.
If I remove these, then special characters like semicolon (;) ruins the template, and not all list elements will be shown.
How can I keep using special characters and avoid the single quotes (') to appear on my document?
some text here
1. [onshow;if [onload.missingFileEnabled;noerr] = ’1’; then ' Lorem ipsum
dolor sit amet, consectetur adipiscing elit.
• [test.x;block=tbs:listitem]
Aliquam a commodo lacus. Proin elit sapien, ultrices vel odio ac, ultricies ipsum ';magnet=w:p]
The relevant php codes:
// Create list data
$contentValues = array("missingFileEnabled" => "1", "testListItem1" => "Test; 1", "testListItem2" => "test 2", "testListItem3" => "test 3");
// Since multiple lists has to be supported, the list is converted into a list of list data.
$listItems = array();
foreach ($contentValues as $key => $value) {
if (strpos($key, 'ListItem') !== false && endsWith($key, 'Reservation') === false && endsWith($key, 'Description') === false) {
// echo "test<br>";
$keyParts = explode("ListItem", $key);
$listItems[$keyParts[0]][] = array("x" => str_replace("'", "’", $value));
}
}
// Then for each list, we merge the data
foreach ((array)$listItems as $listName => $list) {
$TBS->MergeBlock($listName, $list);
}
// Show the end file
$TBS->Show(OPENTBS_DOWNLOAD, $output_file_name);
Instead of using a conditional field (with parameter magnet
), it is better in your case to use a conditional block (parameter when
).
It is more rigorous and easier to read.
Here is what you can do (parameter block=3*tbs:p
defines a block over 3 paragraphes):
1. [onshow;when [onload.missingFileEnabled;noerr] = ’1’; block=3*tbs:p] Lorem ipsum
dolor sit amet, consectetur adipiscing elit.
• [test.x;block=tbs:listitem]
Aliquam a commodo lacus. Proin elit sapien, ultrices vel odio ac, ultricies ipsum