Categories > TinyButStrong general >

Variable number of tables with dynamic columns

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Adilson
Date: 2011-07-28
Time: 23:45

Variable number of tables with dynamic columns

Hi all,

I'm trying to create a variable number of tables with dynamic columns in a ODS file but I can't manage to.

First I manage to create dynamic tables following the example:

Template:

[r.[c.val;block=table:table-cell;p1];block=table:table-row;p1]

PHP:

$nbr_row = 5;
$nbr_col = 5;

// List of column's names
$columns = array();
for ($col=1;$col<=$nbr_col;$col++) {
    $columns[$col] = 'column_'.$col;
}

// Creating data
$data = array();
for ($row=1;$row<=$nbr_row;$row++) {
    $record = array();
    for ($col=1;$col<=$nbr_col;$col++) {
        $record[$columns[$col]] = 'Hello!';
    }
    $data[$row] = $record;
}

// Expanding columns
$TBS->MergeBlock('c',$columns);

// Merging rows
$TBS->MergeBlock('r',$data);
$TBS->Show();

Then I tried to add a variable number of tables:

Template:

[tables.val;block=table:table-row]

PHP:

$nbr_tab = 5;

// List of column's names
$tables = array();
for ($tab=1;$tab<=$nbr_tab;$tab++) {
    $tables[] = '[r.'.$tab'.[c.val;block=table:table-cell;p1];block=table:table-row;p1]';
}

// then add the tables

The code replaces the template "[tables...]" with the template for the dynamic table "[r.[c.val;block=table:table-cell;p1];block=table:table-row;p1]", but after that It doesn't replaces the last template with the dynamic table. Someone managed to do it?

Best,

Adilson
By: Skrol29
Date: 2011-07-29
Time: 04:03

Re: Variable number of tables with dynamic columns

> but after that It doesn't replaces the last template with the dynamic table.

This may be because of the protection against injection.
See http://www.tinybutstrong.com/manual.php#html_field_prm_protect

Bu why are you using parameter "p1" ?