Search code examples
phpopentbs

OpenTBS doesn't generate dynamic columns


So I will start giving a little of context, in my actual project I'am trying to use a library called OpenTBS to generate dynamical columns into an odt, I followed the documentation and it gives me this error:

TinyButStrong Error in block's definition [b.thin...]: at least one tag corresponding to tbs is not found. Check opening tags, closing tags and embedding levels.

TinyButStrong Error Show() Method: The output is cancelled by the OpenTBS plugin because at least one error has occured.

My code looks like this:

<?php
include_once('tbs_class.php');
include_once('plugins/tbs_plugin_opentbs.php');

$TBS = new clsTinyButStrong;
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);

$TBS->LoadTemplate('template.odt',OPENTBS_ALREADY_UTF8);
$data = array(
    array('date' => '2013-10-13', 'thin' => 156, 'heavy' => 128, 'total' => 284),
    array('date' => '2013-10-14', 'thin' => 233, 'heavy' =>  25, 'total' => 284),
    array('date' => '2013-10-15', 'thin' => 110, 'heavy' => 412, 'total' => 130),
);
$TBS->MergeBlock('b', $data);



// $TBS->Plugin(OPENTBS_DEBUG_INFO, true); 

$output_file_name ="test_download.odt";
$TBS->Show(OPENTBS_DOWNLOAD, $output_file_name); 
?>

and the template.odt, looks like this:

 ------------------------------------------------
|Category | [b.date]                             |
|Thin     | [b.thin;block=td;parallel=tbs:table] |
|Heavy    | [b.heavy]                            |
|Total    | [b.total]                            |
 ------------------------------------------------

So, for what I have tested I conclude that the error comes from the odt, here [b.thin;block=td;parallel=tbs:table], to be specific this part: block=td (!!for what I tested!!), because when I use block=td, it doesn't download the odt and it shows up the error only, however when I tried to change block=td to tbs:cell,it worked.The problem is thats it doesn't iterate the arrays, it only shows the first array:

 -------------------------------------------------
|Category | 2013-10-13                            |
|Thin     | 156                                   |
|Heavy    | 128                                   |
|Total    | 284                                   |
--------------------------------------------------

When in reality, the output should be like this:

 -------------------------------------------------
|Category | 2013-10-13 | 2013-10-14 | 2013-10-15  |
|Thin     | 156        | 233        | 110         |
|Heavy    | 128        | 25         | 412         |
|Total    | 284        | 284        | 130         |
--------------------------------------------------

If anybody knows what's going on, please let me know!

Thanks!


Solution

  • Okay, so I think I found a solution, in the odt where it says block=td (in my case), I had to change it to block=tbs:cell, and it worked