TinyButStrong - the PHP Template Engine
Categories > TinyButStrong general >

Problem with subblock

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

By: JL
Date: 2010-09-20
Time: 13:25

Problem with subblock

Hello!

I'm using TBS as a template engine in my project and so far everything has worked like a charm!, but I haven't yet managed to get subblocks working:

In my template I'm initializing automatic subblock like this:

[main.name;sub1=parts]
...
[main_sub1.name]

and in php I use following array to deliver the data for TBS:

MAIN:
Array
(
       [0] => Array
                (
                    [name] => name of main
                    [id] => some other data
                    [parts] => Array
                        (
                            [0] => Array
                                (
                                    [name] => parts name
                                )

                            [1] => Array
                                (
                                    [name] => part2 name
                                )
                            [2] => Array
                                (
                                    [name] => part3 name
                                )
                      )
            )
  )

But when I merge & show this with TBS, it just renders the text [main_sub1.name] where parts names should come. But main level it renders correctly.
So I would like to know if I'm doing something wrong here or if there is some good way to debug and find out what goes wrong here?

Any help would be greatly appreciated!


By: TomH
Date: 2010-09-20
Time: 17:37

Re: Problem with subblock

Your code in nearly complete - just forgot to include the 'block' attibutes for both main and sub
I'll try to illustrate..
<blok_m>
[main.name;block=blok_m;sub1=parts;noerr]
  <blok-s>
  [main_sub1.name;block=blok-s;noerr]<br>
</blok-s>
<br>
</blok-m>

See if that works

TomH

By: TomH
Date: 2010-09-20
Time: 20:17

Re: Problem with subblock

Sorry about the typo error

<blok_m>
[main.name;block=blok_m;sub1=parts;noerr]
  <blok_s>
  [main_sub1.name;block=blok_s;noerr]<br>
</blok_s>
<br>
</blok_m>

Cheers,
TomH
By: JL
Date: 2010-09-22
Time: 09:25

Re: Problem with subblock

Thanks! Now it works!
By: JL
Date: 2010-09-29
Time: 12:23

Re: Problem with subblock

Hello!

is it possible to have subblock in subblock? I was wondering if I would have array structure like this:

MAIN:
Array
(
       [0] => Array
                (
                    [name] => name of main
                    [id] => some other data
                    [parts] => Array
                        (
                            [0] => Array
                                (
                                    [name] => parts name
                                    [subparts] => Array
                                    (
                                         [0] => Array
                                         (
                                              [name] => subparts name
                                         )
                                    )
                                )

                            [1] => Array
                                (
                                    [name] => part2 name
                                    [subparts] => Array
                                    (
                                         [0] => Array
                                         (
                                              [name] => subpart2 name
                                         )
                                    )
                                )
                            [2] => Array
                                (
                                    [name] => part3 name
                                    [subparts] => Array
                                    (
                                         [0] => Array
                                         (
                                              [name] => subpart3 name
                                         )
                                    )
                                )
                      )
            )
  )

This is similar to my earlier post in this thread, but with those added arrays.. If it is not possible to have those subblocks of subblocks, then what would be a better way to program these lists within lists? Subtemplates?

Any help would be greatly appreciated again! :)
By: TomH
Date: 2010-09-29
Time: 16:55

Re: Problem with subblock

Hi again,

Did you try coding those sub_subblocks?

What errors idi you get?
By: JL
Date: 2010-10-04
Time: 13:18

Re: Problem with subblock

Hi!

well.. :) actually I hadn't realized that I could actually do those subblock recursively so I hadn't tried it yet, but now I just wrote that part_sub1_sub1 thing there and it worked!

So no problems after all, should have just tried it :).

By: Ralph7
Date: 2014-11-14
Time: 20:04

Re: Problem with subblock

Hi everybody!

I have a problem with merging  subblock in subblock. I've tried to use it recursively without success.

I get this error:
"Fatal error: Uncaught exception 'tinyDocException' with message 'key 'detail_cpte' is not found in record #1 of block [detail_sub1]. This key can become optional if you designate it with parenthesis in the main block, i.e.: sub1=(detail_cpte)' in /u01/yobapp/web/ws41/trunk/www/lib/edition/tinyDoc-1.0.3/lib/tinyDoc.class.php:1578 Stack trace: #0 /u01/yobapp/web/ws41/trunk/www/lib/edition/tinyDoc-1.0.3/lib/tbs_class.php(2473): tinyDoc->meth_Misc_Alert('for merging the...', 'key 'meth_Merge_SectionNormal(Object(stdClass), Object(clsTbsDataSource)) #2 /u01/yobapp/web/ws41/trunk/www/lib/edition/tinyDoc-1.0.3/lib/tbs_class.php(2001): clsTinyButStrong->meth_Merge_BlockSections('"



In my template(.odt) I'm initializing automatic subblock in subblock like this:

[detail.cod_class;block=table:table-row;sub1=list_cpte]
[detail_sub1.cod_cpte;block=table:table-row;sub1=detail_cpte]  (- level 1 is OK)
[detail_sub1_sub1.lib_ecrit;block=table:table-row]  (- level 2 is not working)


And I have an array structure like this:

detail:

Array
(
    [0] => Array
        (
            [list_cpte] => Array
                (
                    [0] => Array
                        (
                            [cod_cpte] => 401000003
                            [lib_cpte] => toto
                            [cod_cpte_pere] => 401
                            [typ_cpte] => E
                            [detail_cpte] => Array
                                (
                                    [0] => Array
                                        (
                                            [num_lot] => 6
                                            [cod_jrnl] => 2
                                            [lib_ecrit] => 2 20141029 3 FONGANG
                                            [dat_ecrit] => 29/10/2014
                                            [debit] =>
                                            [credit] => 179.4
                                            [solde] => -179,40
                                            [num_lettrag] =>
                                        )

                                    [1] => Array
                                        (
                                            [num_lot] => 7
                                            [cod_jrnl] => 2
                                            [lib_ecrit] => 2 20141029 3 toto
                                            [dat_ecrit] => 29/10/2014
                                            [debit] =>
                                            [credit] => 179.4
                                            [solde] => -358,80
                                            [num_lettrag] =>
                                        )


Any help would be greatly appreciated ! Thanks by advance.

By: Mark
Date: 2015-09-30
Time: 23:10

Re: Problem with subblock

Did you end up getting this to work?
I am having a the same error in a Word DocX file with basically the exact same logic.
It basically can't find the relationship (the 2nd sub 1) in the first sub1.
By: Ralph7
Date: 2015-10-01
Time: 13:29

Re: Problem with subblock

Hi Mark,

Yes, I'd finnally get this work okay.

But it was not a particular issue... you can follow that link, and try to see :

http://www.tinybutstrong.com/forum.php?thr=3459#m14604
By: Mark
Date: 2015-10-01
Time: 14:28

Re: Problem with subblock

So it was basically right, but something under the covers was not working?
Althoguh I am not 100% what you mean by your ODT template?
By: Ralph7
Date: 2015-10-01
Time: 17:57

Re: Problem with subblock

Exactly!

By odt Template, I mean my Open Office Writer (actually, LibreOffice Writer) template file !

If yourproblem persist, you can also post the detais here so that we could check with you...
By: Ralph7
Date: 2015-10-02
Time: 11:39

Re: Problem with subblock

Exactly!

By odt Template, I mean my Open Office Writer (actually, LibreOffice Writer) template file !

If your problem persist, you can also post the detais here so that we could check with you...