By: Osof
Date: 2017-03-02
Time: 12:49
|
sub-sub-sub blocks
Hi. Need help with some sub-sub-subblocks :)
I wish to make document like this:
Section 1
|-------------------|------|------|
| Name list | 2010 | 2011 |
-----------------------------------
| name1 | 50 | 46 |
-----------------------------------
| name2 | 33 | 43 |
-----------------------------------
Section 2
|-------------------|------|------|------|
| Name list | 2013 | 2014 | 2015 |
------------------------------------------
|name3 | 20 | 46 | 51 |
------------------------------------------
|name4 | 34 | 13 | 25 |
------------------------------------------
|
[indexes;block=begin;sub1=indexrows;sub2=years] <--- repeating section blocks on the page
[indexes.iname] <--- here we have some section name
|----------------------------------------------------------|-----------------------------------------------------|
| Name list |[indexes_sub2.name;block=tbs:cell;parallel=tbs:table]|
|----------------------------------------------------------|-----------------------------------------------------|
| [indexes_sub1.name;block=tbs:row;sub1=valueindex] | [indexes_sub1_sub1.ival;block=tbs:cell] |
|----------------------------------------------------------|-----------------------------------------------------|
[indexes;block=end;]
|
And here my php array:
$indexes = [
['iname'=>'Section1',
'years'=>[
0=>['name'=>2011],
1=>['name'=>2012],
],
'indexrows'=>[
0=>[
'name'=>'Name1',
'valueindex'=>[
0=>[
'ival'=>50
],
1=>[
'ival'=>46
]
]
],
1=>[
'name'=>'Name2',
'valueindex'=>[
0=>[
'ival'=>33
],
1=>[
'ival'=>43
]
]
]
]
],
['iname'=>'Section2',
'years'=>[
0=>['name'=>2013],
1=>['name'=>2014],
2=>['name'=>2015],
],
'indexrows'=>[
0=>[
'name'=>'Name3',
'valueindex'=>[
0=>[
'ival'=>20
],
1=>[
'ival'=>46
],
2=>[
'ival'=>51
]
]
],
1=>[
'name'=>'Name4',
'valueindex'=>[
0=>[
'ival'=>34
],
1=>[
'ival'=>13
],
2=>[
'ival'=>25
]
]
]
]
]
];
After $OpenTBS->MergeBlock('indexes', $indexes); a get table like this
|Name list| 2011 | 2012 |
| name1 | value1 | value1 | value2|
|
What I am doing wrong? Thank you for help!
|
By: Skrol29
Date: 2017-03-02
Time: 23:01
|
Re: sub-sub-sub blocks
Hi Osof,
The snipped is wrong because the cell in the middle ("indexes_sub1_sub1") is merged twice : one by colums (block "indexes_sub2"), once by rows (block "indexes_sub1").
You have to merge first the colmuns, and the the rows. So then rows.
Here is a snipped that works (tested with your data, thanks by the way...)
[indexes;block=begin;sub1=years;sub2=indexrows] <--- TAKE CARE THERE IS A CHANGE HERE
[indexes.iname]
|------------------------------------|------------------------------------------------------|
| Name list |[indexes_sub1.name;block=tbs:cell;parallel=tbs:table] |
|-------------------------------------------------------------------------------------------|
| [indexes_sub2.name;block=tbs:row] | [indexes_sub2.valueindex.[indexes_sub1.$].ival] |
|------------------------------------|------------------------------------------------------|
[indexes;block=end;]
|
With OpenTBS, I do suggest to use the TBS relative syntax for block in the document (not using "block=begin", "block=end"). It prevents from XML errors.
Here is what it becomes with your template:
[indexes.iname;block=tbs:p+tbs:table;sub1=years;sub2=indexrows]
|------------------------------------|------------------------------------------------------|
| Name list |[indexes_sub1.name;block=tbs:cell;parallel=tbs:table] |
|-------------------------------------------------------------------------------------------|
| [indexes_sub2.name;block=tbs:row] | [indexes_sub2.valueindex.[indexes_sub1.$].ival] |
|------------------------------------|------------------------------------------------------|
|
|