Hello,
I am trying to achieve quite the same thing whitout success.
I have a basic template file :
$BLOCK_EXAMPLE$
Some not dynamic content.
Some dynamic content : $dynamic$
---
$BLOCK_EXAMPLE$
The cloning part works fine :
$datas = [];
for ($i=0;$i<5;$i++) {
$docx->cloneBlock('EXAMPLE');
$datas[] = 'number' . $i;
}
But the part where I try to populate all the differents $dynamic$ var with $datas doesn't :
foreach ($datas as $key => $item) {
$docx->replaceVariableByHtml('dynamic', 'block', $item);
}
I end up with :
Some not dynamic content.
Some dynamic content : number0
---
(...)
---
Some not dynamic content.
Some dynamic content : number0
---
I don't know what I'm doing wrong.
And I couldn't find any example with blocks having dynamic content inside in them. I've only find examples with blocks and static content inside.
Thanks for your help.