TinyButStrong - the PHP Template Engine
Categories > TinyButStrong general >

Dynamic columns with sections in 1 table

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Edwin Stas
Date: 2016-02-26
Time: 13:21

Dynamic columns with sections in 1 table

With the dynamic columns 1 example, I’m trying to do following: Whit in 1 table, a need sections that are separated by a row with colspan (depending on the number of rows)
I don’t know if TBS supports this?
This is my code:
<table border="1" cellpadding="3" cellspacing="0" style="margin-left:auto; margin-right:auto;">
      <tr>
        <td width="60" align="center" class="cell-0">X</td>
        <td align="center" class="cell-front">[c.key;block=td;parallel=tbs:table] </td>
      </tr>
      <tr>
        <td align="center" class="cell-front">[r.$;block=tr]</td>
        <td align="center" class="cell-1">[r.[c.val]] </td>
      </tr>
      <tr>
        <td align="center" class="cell-front">[r.$;block=tr]</td>
        <td align="center" class="cell-2">[r.[c.val]] </td>
      </tr>
      <tr>
        <td  colspan="[onload.acols]" align="center" class="cell-0">TEST</td>
      </tr>
…next section
</table>

Php script added this line:
$TBS->VarRef['acols'] = $nbr_col;

The error I’m getting is:
TinyButStrong Error Parallel: At row 4 having entity [tr],the column 2 is missing or is not the first in a set of spanned columns. (The block is defined from column 2 to 2)

TinyButStrong Error in field [r....]: item '' is not an existing key in the array. This message can be cancelled using parameter 'noerr'.

By: Edwin Stas
Date: 2016-02-29
Time: 14:02

Re: Dynamic columns with sections in 1 table for product compare script

After reading the online manual I see that it will not work with section grouping. I was looking for a way to rewrite my current "product compare" script using TBS functionality. I think it is possible if I build my array in such a way that it will contain styling elements which can be used to make it look as if there are sections.
By: Skrol29
Date: 2016-03-01
Time: 00:48

Re: Dynamic columns with sections in 1 table for product compare script

ok
By: Edwin Stas
Date: 2016-03-03
Time: 08:17

Re: Dynamic columns for product compare script

I’m using a slightly different approach regarding the use of dynamic columns. Only the columns are dynamic and the rows are handled by the template.
<table class="ep_kader">
<tbody>
<tr>
    <td class="kol1">[onload.epartnr]</td>
    <td class="kols">[da.artnr;block=td;parallel=tbs:table]</td>
</tr>
<tr>
    <td class="kol1">[onload.eptype]</td>
    <td class="kols">[da.ep_type;magnet=tr]</td>
</tr>
…..
This all works great except for the magnet part. If a row inside the array (da) is empty I need to remove that row. The magnet=tr does not work in this situation. How can I remove a row that does not contain data?
By: Edwin Stas
Date: 2016-03-03
Time: 13:42

Re: Dynamic columns for product compare script

So this is what I did to make it work (workaround)

<table class="ep_kader">
<tbody>
<tr>
    <td class="kol1">[onload.epartnr]</td>
    <td class="kols">[da.artnr;block=td;parallel=tbs:table]</td>
</tr>
<tr>
    <td class="kol1 [c.ep_type;magnet=tr]">[onload.eptype]</td>
    <td class="kols">[da.ep_type]</td>
</tr>
………
Together with the data array[da], there is also a control array[c] which contains the same variables as the data array. The value in the control array is an indicator to tell that all fields from the dynamic columns of the data array are empty or not.

When using the control array inside a class [c.ep_type;magnet=tr] (like the example above) on the first column, the rows that are empty will be removed. Super ;-)

Still wondering why the magnet is not working in the dynamic columns.