Categories > TinyButStrong general >

Merge Table with column instead of rows

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Peter
Date: 2015-07-22
Time: 10:18

Merge Table with column instead of rows

Hello,
i need an table with merging cols instead of rows, but if i work with parallel it doesn't seem to work. What is wrong in my code?

The Array:

$data=array(
array('name'=>'name1 for col1' ,'price'=>20.1,'price2'=>20.1),
array('name'=>'name2 for col2','price'=>22.1,'price2'=>23.1),
array('name'=>'name3 for col3','price'=>21.1,'price2'=>24.1)
);

The Template:

<table>
    <thead>
    <tr>
        <td>Product</td>
        <td>[list.Name;noerr;block=td;parallel=tbs:table]</td>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td class="lighter">Price</td>
        <td class="lighter">[list.price;noerr]</td>
    </tr>
    <tr>
        <td class="dark">Price2</td>
        <td class="dark">[list.price2;noerr]</td>
    </tr>
    <tr>
        <td></td>
        <td class="dark">Order</td>
    </tr>
    </tbody>
</table>
By: Skrol29
Date: 2015-07-30
Time: 11:00

Re: Merge Table with column instead of rows

Hi Peter,

This is because of tags <thead> and <tbody>.

TBS 3.9.0 does not support them yet.

So you have to delete them from the template or to redefine the « tbs:table » configuration with the following code :
$conf = array(
    'parent' => 'table',
    'ignore' => array('!--', 'caption', 'thead', 'thbody', 'thfoot', 'thead', 'tbody'),
    'cols' => array(),
    'rows' => array('tr'),
    'cells' => array('td'=>'colspan', 'th'=>'colspan'),
);
$TBS->SetOption('parallel_conf', 'tbs:table', $conf);