Categories > OpenTBS with ODT >

using several block to make a complex open office document

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: jacques
Date: 2012-08-07
Time: 16:20

using several block to make a complex open office document

I would like to do the following.
I have a template with n different block defined for the moment a, b, c.
I have a list of user data that should be merged with the a block a,b or c depending on what the user choice.
Merging a list of user against a, b or c is not a problem. I know how to do it. But then I would like to reorder the pages so that it match a given order.

Here is an exemple to make it clear :

user 1 should be merged with block a
user 2 should be merged with block b
user 3 should be merged with block a
user 4 should be merged with block c
user 5 should be merged with block a.

I want to have in my open office document a list of user datas ordered from 1 to 5 with each using the assigned block.
I am convinced it should be quite easy to do, but couldn't find such thing in the documentation.

Right now, I can order the merge so that I merge user 1,3,5 to block a and user 2 with block b and user 3 with block c.
How to reorder the thing correctly afterwards ?
It is nothing more than switching some page around, but I cannot find the right tool to do it.
Would somebody give me a hint of which command could do such a thing.

Thank you,
Best regards
By: Skrol29
Date: 2012-08-07
Time: 23:07

Re: using several block to make a complex open office document

If blocks a, b, c have only one section each, then you can try to make blocks a, b, c to be conditional sections of a unique block "u".

[u;block=tbs:page;when [u.type]=a]
   same as block A
[u;block=tbs:page;when [u.type]=b]
   same as block B
[u;block=tbs:page;when [u.type]=c]
   same as block C

By the way, "block=tbs:page" is a new feature of OpenTBS version 1.8.0 which is available in beta version.
"tbs:page" is an alias of block for the delimited page.
By: jacques
Date: 2012-08-08
Time: 08:22

Re: using several block to make a complex open office document

Yes, I think that is what I need. I will give it a try.
Thank you
By: jacques
Date: 2012-08-09
Time: 09:09

Re: using several block to make a complex open office document

I tried and it worked fine.
I had to modified line 3019 of the source code of tbs_plugin_opentbs.php. Changed from $o to $s.
I think it might have been a typing mistake in opentbs 1.8 beta.
strict mode in php5 gives a warning about use of uninitialised variable.

This is the small test case that I wrote that works fine with a template as you suggested with one block per page :
<?php

include_once('../tbs_class.php');
include_once('../tbs_plugin_opentbs.php');

$user=array();
$user[] = array( "name" => "usera",
  "type" => "a" );
$user[] = array( "name" => "userb",
  "type" => "b" );
$user[] = array( "name" => "usera1",
  "type" => "a" );
$user[] = array( "name" => "userb1",
  "type" => "b" );

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

$TBS->LoadTemplate('/homez.10/beranjaq/www/opentbs/test/demo_oo_text.odt');

$TBS->MergeBlock('u','array', $user);

$TBS->Show(OPENTBS_DOWNLOAD);
?>
Thank you,
By: Skrol29
Date: 2012-08-09
Time: 23:43

Re: using several block to make a complex open office document

Thanks for this bug fix.
I will update the beta in few days.

Regards,