Categories > TinyButStrong general >

query and subblock

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Kim
Date: 2012-10-26
Time: 00:28

query and subblock

Hi

I have a sql-query returning something like this :

One, Yellow
One, Red
One, Blue
Two, Red
Two, Green
...

I'm trying to get something like this, using automatic subblocks :

-------------------------------
                 Yellow
One          Red
                 Blue
-------------------------------
Two           Red
...
-------------------------------

But I get :

-------------------------------
one          Yellow
-------------------------------
one          Red
...

My template (simplified) :

<table>
<tr>
<td>[blk.number;block=tr;sub1=color]</td>
<td><div>[blk_sub1.val;block=div]</div></td>
</tr>
</table>

Any ideas what's wrong ?

Thanks, Kim
By: Skrol29
Date: 2012-10-26
Time: 02:32

Re: query and subblock

Hi Kim,

Your HTML code is using the syntax for automatic sub-blocks, it assumes that column "color" contains an array of data.

For the flat data given by your query, you should use a block with a grouping section:
<table>
  <tr>
    <td>[blk.number;block=tr;parentgrp=number]</td>
    <td><div>[blk.color;block=div]</div></td>
  </tr>
</table>

By: Kim
Date: 2012-10-26
Time: 10:23

Re: query and subblock

Thanks, I'll try

It may be my understanding of the manual that's at fault, but I believe I have based my template on the example in the manual :

Example:
Name: [body.name;block=tr;sub1=spokenlg]
[body_sub1.val;block=tr]

Corresponding PHP code:
$TBS->MergeBlock('body',$cnx_id,'SELECT name,spokenlg FROM t_body)

Result of the merge:
Name: Peter
US
FR
Name: Paul
US
Name: Jack
FR
ES
IT

I did wonder how TBS did this, but until now it has surprised me a lot, so you never know.

Keep up the good job.

Kim.
By: Skrol29
Date: 2012-10-26
Time: 16:01

Re: query and subblock

You're right, this is an error in the manual.
It will be fixed soon.
Thanks,
By: Kim
Date: 2012-10-26
Time: 23:28

Re: query and subblock

I have another question now I have your attention ;)

To return to my previous example, if my query returns :

One, Yellow, House
One, Red, Car
One, Blue, Train
Two, Red, Car

And I would like to have it formatted thus :

------------------------------------------
            |     Yellow  | House
One     |     Red       | Car
            |     Blue     | Train
------------------------------------------
Two      |     Red     | Car
...

I would expect the template to look something like this :

<table>
    <tr>
      <td>[Blk.Number;block=tr;parentgrp=Number]</td>
      <td><div>[Blk.color;block=div]</div></td>
      <td><div>[Blk.type;block=div]</div></td>
    </tr>
</table>

But I get this :

------------------------------------------
            |     Yellow  |
           |      House   |
One     |     Red       |
           |    Car        |
            |     Blue     |
            |    Train    |
------------------------------------------

And if I remove the block parameter from the Blk.type field, I get :

------------------------------------------
            |     Yellow  | House
One     |     Red       |
            |     Blue     |
------------------------------------------
Two      |     Red     | Car
...

Better but still not right !

Any idea how I should do it ?

Kim
By: Skrol29
Date: 2012-10-28
Time: 23:45

Re: query and subblock

Hi Kim,

What you're trying to do is corresponding to displays records with a breaked structure: <div> and <td>.
This can be done with TBS using parameter "serial".
Unfortunately "serial" does not work with "headergrp".

The solution could be to change the structure of you data, using automatic sub-blocks it could me easier.