TinyButStrong - the PHP Template Engine
Categories > [old] TbsOoo & TinyDoc >

encapsulation problem with openoffice

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

By: pupah
Date: 2010-07-02
Time: 17:58

encapsulation problem with openoffice

This is my query. My proble is how write in openoffice this block:
$OOo->MergeBlock('blk_cc',$cc);
$OOo->MergeBlock('blk_mm',$mm);

$cc=$db->query("select first_name.id
from contacts where contacts.deleted=0");
$contacts=array();
while($c=$db->fetchByAssoc($cc)){
    $contacts[]=$c;
   

    $mm=array();
    $a=$db->query("select accounts.name
            from accounts
            join project_contacts on project_contacts.contact_id = contacts.id and project_contacts.deleted=0
            where accounts.contact_id='{$c['id']}' and accounts.deleted=0");
    while($k=$db->fetchByAssoc($a)){
        $mm[]=$k;
    }
   
}


In my openoffice I need a table that show my contacts and for each of them the linked accounts. so I try to show this with 2 table: table b inside table A.
So in the first table A I wrote something like this:
[blk_cc.first_name;block=table:table-row]
and in a second table B inside the first table A a wrote:
[blk_cc.blk_mm.name;block=table:table-row]

but is not correct..help..
By: Skrol29
Date: 2010-07-03
Time: 01:10

Re: encapsulation problem with openoffice

hi Pupah,

The PHP snippet you've posted do not produce a correct data representation. After it is run, $mm contains only accounts names of the last contact, and $cc contains a resource id. But what ever, I think I have the idea of what you're trying to do.

In order to perform your encapsulation, you just have to use TBS sub-blocks. They are described in the online examples. Go and see here
  http://www.tinybutstrong.com/examples.php
and choose the Sub-block Example. It works exactly the same way for HTML or OpenOffice, you just have to take in account that the row entity in an OO table is "table:table-row".

Assuming that the $contacts array contains records having an "id" column and an "mm" column. And that the mm column contains the records having a "name" column. Then you can build your template with a table [A] with:
[blk_cc.id;block=table:table-row;sub1=mm]
and a table [B] placed inside table A with:
[blk_cc_sub1.name;block=table:table-row]
(not tested)