Categories > TinyButStrong general >

Block not rendered, I'm becoming crazy!!!

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: flodi
Date: 2016-09-14
Time: 16:28

Block not rendered, I'm becoming crazy!!!

i have a complex situation where a block is not being rendered, and I'm becoming crazy trying to figure out why. If someone can help, I'll be very grateful.

I'm going to simplify it a lot.

I execute this code:
    switch($action) {
        case "add":

where "add.php" is
    $sql="select * from categories order by name";

At the end, $category contains
    [0] => Array
            [id] => 2
            [name] => Abbigliamento
            [avgvalue] => 0
            [id_creator] => 1
            [created] => 2016-09-14 07:06:48

    [1] => Array
            [id] => 1
            [name] => Cibo e Bevande
            [avgvalue] => 0
            [id_creator] => 1
            [created] => 2016-09-14 07:05:16


Then I load a template like that

<h2>Gestione Beni</h2>
[onshow;file=/home/pwrs/;when action='add']

than calls a subtemplate like that

<h3>Aggiungi Bene</h3>

<form id="mainform" action="/pwrs/goods/add/" method="post">
    <input type="hidden" name="db" value="1">
    <div class="form-group">
        <label for="id_category">Categoria</label>
        <select class="form-control" id="id_category" name="id_category">
            <option value="[;block=option]">[]</option>
more html

But instead of having the content of $categories replaced in the block, I get the TBS directives printed on screen as they are. TBH, it seems no TBS code is replaced. The subtemplate is loaded but not parsed.

What I'm doing wrong?

By: Skrol29
Date: 2016-09-15
Time: 17:55

Re: Block not rendered, I'm becoming crazy!!!

Hi Flodi,

Your field « [onshow;file=...] » is merged at the very end, when you cann $TBS->Show(), not before.
That's why, when you do MergeBlock("bCategories"), that is before Show() as I can guess, the corresponding block is not yet existing in the template.

You have to use [onload] instead of [onshow], or use a field that you manually merge with MergeField().
By: flodi
Date: 2016-09-16
Time: 09:20

Re: Block not rendered, I'm becoming crazy!!!

Dho! Homer moment.

Of course, you're right.