【问题标题】:Is it possible to use a subblock on a subblock when creating docx with opentbs?使用opentbs创建docx时是否可以在防晒霜上使用防晒霜?
【发布时间】:2019-06-23 15:42:13
【问题描述】:

我正在尝试使用 opentbs 插件将数组输出到 docx 文件。我的数组有一个嵌套数组,所以我对主数组使用一个块,而对嵌套数组使用一个子块。这完美地工作。我的问题是嵌套数组也有自己的嵌套数组。可以用子子块输出吗?

以下是我在 docx 模板中使用的内容,货件数据(块)和条目数据(子块)按我的需要显示。对于每个条目,我需要显示包(子子块),但目前它只输出标签而不是包数据。我哪里错了?

[a.shipment_#; block=tbs:row;sub1=entries]  
   [a_sub1.id]  
   [a_sub1.shipping_name;block=tbs:row;sub2=packs] 
   [a_sub1.total_quantity]  
        [a_sub2.display_line;block=tbs:row]
[a_shipment_total]

这是数组:

Array
(
    [0] =>; Array
        (
            [entries] =>; Array
                (
                    [1] =>; Array
                        (
                            [id] =>; 10000
                            [shipping_name] =>; Name1
                            [total_quantity] =>; 135                           
                            [packs] =>; Array
                                (
                                    [0] =>; Array
                                        (
                                            [display_line] =>; 6 Steel Drums x 10L
                                        )

                                    [1] =>; Array
                                        (
                                            [display_line] =>; 5 Steel Drums x 15L
                                        )

                                )

                        )

                    [2] =>; Array
                        (
                            [id] =>; 100001
                            [shipping_name] =>; Name2 
                            [total_quantity] =>; 50                           
                            [packs] =>; Array
                                (
                                    [0] =>; Array
                                        (
                                            [display_line] =>; 2 Plastic Jerry Cans x 25L
                                        )

                                )

                        )

                    [3] =>; Array
                        (
                            [id] =>; 10002
                            [shipping_name] =>; Name3
                            [total_quantity] =>; 170                          
                            [packs] =>; Array
                                (
                                    [0] =>; Array
                                        (
                                            [display_line] =>; 1 Plastic Jerry Can x 20L
                                        )

                                    [1] =>; Array
                                        (
                                            [display_line] =>; 6 Plastic Jerry Cans x 25L
                                        )

                                )

                        )                    

                )

            [shipment_id] =>; #1234
            [shipment_total] =>; 355
        )

)

【问题讨论】:

    标签: php opentbs tinybutstrong


    【解决方案1】:

    子块功能确实支持子子块。

    区块a_sub1是区块a的子区块。

    a_sub1_sub1是块a_sub1的子块,因此它是'a'的子子块。

    您的模板可以是这样的:

    [a.shipment_id;block=tbs:row;sub1=entries]  
       [a_sub1.id]  
       [a_sub1.shipping_name;block=tbs:row;sub1=packs] 
       [a_sub1.total_quantity]  
            [a_sub1_sub1.display_line;block=tbs:row]
    [a.shipment_total]
    

    【讨论】:

    • 我已经扩展了数组,现在需要一个 sub2。我在示例的第一行中定义了 sub2,如下所示... [a.shipment_id;block=tbs:row;sub1=entries;sub2=overpacks]。这是正确的方法吗?然后我在模板中的 shipping_total 上方添加了 [a.sub2.overpack_item_total;block=tbs:row]。但是,我只得到了 .docx 文件中显示的最后一个 overpack_item_total。
    猜你喜欢
    • 2012-09-09
    • 2017-01-08
    • 1970-01-01
    • 1970-01-01
    • 2014-03-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-26
    • 1970-01-01
    相关资源
    最近更新 更多