Skrol29 / opentbs

With OpenTBS you can merge OpenOffice - LibreOffice and Ms Office documents with PHP using the TinyButStrong template engine. Simple use OpenOffice - LibreOffice or Ms Office to edit your templates : DOCX, XLSX, PPTX, ODT, OSD, ODP and other formats. That is the Natural Template philosophy.
http://www.tinybutstrong.com/opentbs.php
69 stars 17 forks source link

Can I use sub blocks? #9

Closed theopensourcerer closed 4 years ago

theopensourcerer commented 4 years ago

I am trying to create a template in LibreOffice Writer that uses subblocks. I can get the first-level block working but not the second?

The data is in a php array and is in a format like this (which I took from the example in the main docs re: "Automatic subblocks". So what I want to achieve is a table with rows by "moduleName" within each row contains another table of values for the label, name and value from the fieldData array: Screenshot from 2020-04-22 15-37-21

I've tried various forms of the subblock template directive (I tried replacing ".val" with .label, .name and .value obviously) but can never get it to display any data in the rendered document. Here is the relevant part of the template: Screenshot from 2020-04-22 15-36-56

And this is what gets rendered: Screenshot from 2020-04-22 15-45-06

Any ideas? Thanks.

roxblnfk commented 4 years ago

Your subblock should be in the scope of the main block. I assume that the using of the subblock is outside the zone of main block (it is two different rows of same table).

theopensourcerer commented 4 years ago

I've made a small change but still not getting any data rendered in the sub block:
Screenshot from 2020-04-22 16-07-42

roxblnfk commented 4 years ago

If you are sure that the subblock falls within the coverage area of ​​the parent block, then you should make sure that the marker does not contain an excess markup due to copy-paste. To do this, copy the marker text into notepad, and then copy back from there to the template. It often helped me.

theopensourcerer commented 4 years ago

yay!!! Thanks for that! :-D

I'm on Linux so I put the template directives into gedit and pasted them back in.
Screenshot from 2020-04-22 16-21-44

roxblnfk commented 4 years ago

@theopensourcerer by the way, if you need some things (for example, sorting or grouping with calculations), you can watch my fork. There, however, the documentation and examples are very bad, but the additional functionality allows me to generate accounting documents, invoices, sort different lists without changing the php code.