문제

Alright, I'm new to XML and OpenTBS so this concept of blocks etc is very confusing for me, and when I thought I had the gist of it, my client asked for even more of me. I've got a table of customers and their items, the client wants one single docx which repeats a template per customer containing the items in a table.

I'm thinking that it'd work with the whole docx template being in a "block" and the table is a "sub-block", the rest of the template uses data from the block and the table uses data from the sub block.
This is where I get confused.
How can I iterate over an array (which contains customer information) and when the sub block requires information of a specific customer, draw from the items array? For me, the "manual" included with TinyButStrong is not good enough, but I'm sure that you guys will know where to point me.

Simplified Array:

$customer = array(
    array("id" => 1,
        "name" => "Foo Bar",
        "email" => "foo@bar.com",
        "itemsinfo" => array(
            "itemid" => array(
                "itemname" => "name"
            )
        )
    ),
    array("id" => 2,
        "name" => "Foo2 Bar2",
        "email" => "foo2@bar2.com",
        "itemsinfo" => array(
            "itemid" => array(
                "itemname" => "name"
            )
        )
    )
);

Many thanks.

도움이 되었습니까?

해결책

Thank you for adding your array structure. This should work fine with OpenTBS.

So assuming you have something like:

<w:body>[customers;block=w:body;]
    Customer Name: [customers.name;]
</w:body>

In order to get nested information from the customers array you would do:

<w:body>[customers;block=w:body;sub1=itemsinfo]
    Customer Name: [customers.name;]
    Customer Items:
    <w:table>
        <w:tr>
            <w:td>[customers_sub1.itemname;block=w:td;]</w:td>
        </w:tr>
    </w:table>
</w:body>

This would cause the w:td to repeat for each item in the itemsinfo array - probably not your desired behavior but hopefully enough to get you going again. The manual is quite helpful, but it unfortunately makes more sense after you already understand...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top