Categories > OpenTBS with DOCX >

Title hierarchy docx

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: mat
Date: 2014-07-30
Time: 16:21

Title hierarchy docx

Hi!
I'm currently working on a doc generator using OpenTBS but I'm stuck on the generation of a titles tree.

I'd like to create differents title levels but in fact the first level titles appear on all the pages whereas I want them only one time.

Basically, I want to have :
Top Title 1
    Sub Title 1
                Content 1
      Sub Title 2
                Content 2
Top Title 2
    Sub Title 1
                Content 3
    Sub Title 2
                Content 4

But I have :
Top Title 1
    Sub Title 1
                Content 1
Top Title 1
    Sub Title 2
                Content 2
Top Title 2
    Sub Title 1
                Content 3
Top Title 2
    Sub Title 2
                Content 4

My template is :
[r.title; block=tbs:page;sub1=section]
    [r_sub1.title;block=tbs:page]
                [r_sub1.content]

and my php code
        $data[0] = array('title' => "Top Title 1");
        $data[0]['section'][] = array("title" => "Sub Title 1", "content" => "Content 1");
        $data[0]['section'][] = array("title" => "Sub Title 2", "content" => "Content 2");

        $data[1] = array('title' => "Top Title 2");
        $data[1]['section'][] = array("title" => "Sub Title 1", "content" => "Content 3");
        $data[1]['section'][] = array("title" => "Sub Title 2", "content" => "Content 4");
       
        $TBS->MergeBlock('r', $data);
       
        $TBS->Show(OPENTBS_DOWNLOAD, 'file_name.docx');

Any ideas ?

Thanks !
By: Skrol29
Date: 2014-07-30
Time: 23:21

Re: Title hierarchy docx

Hi,

If both "r" and "r_sub1" are defined on the same bounds, then it is a problem. Top title is then inside the sub-block.
Replace
  [r_sub1.title;block=tbs:page]
with
  [r_sub1.title;block=tbs:p+tbs:p]
By: mat
Date: 2014-07-31
Time: 09:30

Re: Title hierarchy docx

Thanks!
I found an other trick but with your answer, I understand now how subsections really work.