Forum


Replies: 1   Views: 1605
List not working when inside an array of word fragments
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 admin  · 28-05-2020 - 16:08

Hello,

Using the following line:

$event_wf->addText($events_array);

all contents are added as inline (block tags are removed).

To accomplish the required task, you need to use a single WordFragment, where you add all content, instead of grouping them with addText:

$event_wf = new WordFragment($phpdocx, 'document');
$event_wf->addText('Text');
$itemList = array(
    'Line 1', // you can add text strings or WordFragments if needed
    'Line 2',
    'Line 3',
    'Line 4',
    'Line 5'
);
$event_wf->addList($itemList, 1);
$event_wf->addText('More text');
$event_wf->addList($itemList, 1);

$docx->replaceVariableByWordFragment(array('DATA_EVENTS' => $event_wf));

WordFragments are very flexible and they allow adding a single content or group of contents.

Regards.