Categories > TinyButStrong general >

2 Questions: Valid Cache File + Dynamic Cols and Rows

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Horst
Date: 2003-08-05
Time: 23:56

2 Questions: Valid Cache File + Dynamic Cols and Rows

Hi there,

first I want to say that this class is very cool.
I love it. Lat days I've created the first page with a clear structure (different files for html and php) with TinyButStrong. =:)
(I'm a beginer in PHP-coding)

I have two questions now:
1) Is it possible to read out if a valid cached file is available without to display it and stopping the script?

2) How can I dynamicaly set the numbers for cells and rows in tables by merging a block?

Now I have a solution like in one of your examples shipped with the class:
<tr>
<td>[bx_1.one;block=td][bx_1.two;block=td]</td>
<td>[bx_2.one;block=td][bx_2.two;block=td]</td>
<td>[bx_3.one;block=td][bx_3.two;block=td][bx;block=row;serial]</td>
</tr>
If I merge the block with an array containing 9 records I get  3 x 3 cells.
Is there a way to create 2x4 or 4x4 or any other combination dynamicaly based on two variables (for cells and rows)?
Or is there a way to set the number for cells by a variable and the maximum number for records to process?


Thank's in advance,
Horst
By: Skrol29
Date: 2003-08-06
Time: 00:49

Re: 2 Questions: Valid Cache File + Dynamic Cols and Rows

Hi Horst,

I'm gald you enjoy TinyButStrong :)

1)
You can avoid the automatic display and exit after the CacheAction() method using the Render Property.
If TBS found a valid cache file then CacheAction() returns True, otherwise, it retun False. But if it returns True, the the content ofthe cache file is loaded into to Source property and this cannot be canceled.

2)
I see a way to make your dynamic table.
Use a first block with a numric value to multiply the TD of your table.
Then merge the second block (wich is serial) with your data.

Example HTML side:
<tr>
  [bx;block=row;serial]
  <td>[bx_[bn.#;block=td].one;block=td][bx_[bn.#].two;block=td]</td>
</tr>

You can notice that the locator with the serial parameter is outside the TD tag.

PHP side:
$nbr_col = 4 ;
$TBS->MergeBlock('bn',$nbr_col) ;
$TBS->MergeBlock('bx',$cnx,'SELECT...') ;
By: Horst
Date: 2003-08-06
Time: 04:51

Re: 2 Questions: Valid Cache File + Dynamic Cols and Rows

Hi Skrol,

thanks for the fast reply.

Point 1) works very well =:)

Point 2) not, I get an Error:
TinyButStrong Error (MergeBlock): Unsupported variable type : 'integer'.
And it doesn't merge the bn.# -MergeBlock-Call.

Now I've changed it a bit. With a for-loop I create an array containing as many numbers needed by my var for columns and this I pass to the first MergeBlock-Call:

PHP:
$cols = array();
for ($x=1; $x<=$spalten; $x++) $cols[] = $x;
$TBS->MergeBlock("bn",$cols);
$TBS->MergeBlock("bx",$data_array);

HTML:
<tr>
  [bx;block=row;serial]
  <td>[bx_[bn.#;block=td].one;block=td][bx_[bn.#].two;block=td]</td>
</tr>

This works and let me dynamicaly create cols and rows.  =:)

Greetings,
Horst
By: Skrol29
Date: 2003-08-06
Time: 10:00

Re: 2 Questions: Valid Cache File + Dynamic Cols and Rows

> TinyButStrong Error (MergeBlock): Unsupported variable type : 'integer'

Yes, my line was wrong. It should be:
$nbr_col = 4 ;
$TBS->MergeBlock('bn','num',$nbr_col) ;
$TBS->MergeBlock('bx',$cnx,'SELECT...') ;