Categories > OpenTBS general >

Nested sub-blocks

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: JohnG
Date: 2014-02-28
Time: 04:26

Nested sub-blocks

Hi,

I have followed some previous guidance on the issue but I'm having issues. Basically I would like something that looks like this:

Section 1
    * Sub-bullet 1 for s1
        *Sub-bullet 1 sub 1
        *Sub-bullet 1 sub 2
    * Sub-bullet 2 for s1
         *Sub-bullet 2 sub1


I'm trying to merge this with a Word template. Here is what my template looks like:
[main.title; block=tbs:row]
       *[sub1.label;block=tbs:listitem;p1=[main.$];bmagnet=tbs:listitem]
             *[sub2.label;block=tbs:listitem;p1=[main.$];p2=[sub1.$];bmagnet=tbs:listitem]
PHP:
$wharr[0]['title'] = 'Section 1';
$wharr[0]['sub'][1]['label'] = "Sub-bullet 1 for s1";
$wharr[0]['sub'][1]['sub'][1]['label'] = "Sub-bullet 1 sub 1";
$wharr[0]['sub'][1]['sub'][2]['label'] = "Sub-bullet 1 sub 2";
$wharr[0]['sub'][2]['label'] = "Sub-bullet 2 for s1";
$wharr[0]['sub'][2]['sub'][1]['label'] = "Sub-bullet 2 sub 1";


$TBS->MergeBlock('main', $wharr);
$TBS->MergeBlock('sub1','array', "wharr[%p1%][sub]");
$TBS->MergeBlock('sub2','array', "wharr[%p1%][sub][%p2%][sub]");

Result:
Section 1
  * Sub-bullet 1 for s1
  * Sub-bullet 2 for s1
        * Sub-bullet 1 sub 1
        * Sub-bullet 1 sub 2

As you can see, the correct sub-bullet sub is not being associated with the main bullet. I followed the guidance from here:http://www.tinybutstrong.com/forum.php?thr=3095 and also tried automated sub-blocks but no luck and different sets of errors. Any thoughts would be greatly appreciated.

John
By: Skrol29
Date: 2014-02-28
Time: 22:58

Re: Nested sub-blocks

Hi John,

The second level of sub-template should be nested in the first level.
But neither ODT nor DOCX does nest the list as we can believe. List items are not nested.

So your template should be:
[main.title; block=tbs:row]
       *[sub1.label;block=tbs:listitem+tbs:listitem;p1=[main.$]]
             *[sub2.label;block=tbs:listitem;p1=[main.$];p2=[sub1.$]]
Note that "bmagnet=tbs:listitem" is useless since it defines the same bound as parameter "block".

The structure of your data seems to enable you to use the automatic sub-block:

PHP:
$TBS->MergeBlock('main', $wharr);

Template:
[main.title; block=tbs:row;sub1=sub]
       *[main_sub1.label;block=tbs:listitem+tbs:listitem;sub1=sub]
             *[main_sub1_sub1.label;block=tbs:listitem]