Categories > TinyButStrong general >

dev and block syntax

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: peirgwnael
Date: 2004-01-14
Time: 18:57

dev and block syntax

Hi
do you think it could be possible to merge a multidimensionnal array  in a near future ?
for example :
<tr>
<td>[block1.data;block=tr][block1.toto]</td>
<td>[block1.sblock.datat2;block=td]</td>
<tr>
Because I think it won't possible to use sub bloc syntax (%p1%) with array.

What a gap between beta 11 and beta 14 with just some days of development ...

Peirgwnael
By: Skrol29
Date: 2004-01-14
Time: 22:30

Re: dev and block syntax

Hi,

>What a gap between beta 11 and beta 14 ...
Is it bad or good ?

I'm still studying the possibility to have queries with array values.
But I don't think it will be ready in a near futur.

But there is an issue for you. You can do it with sub-blocks and custom data functions. I've tested it, it works fine.

Here is the code I've used for the custom data functions.
You'll probably have to change it a bit depending to your sub-array.
function tbsdb_myarray_open(&$Source,&$Query) {
  global $myarray;
  return $myarray[intval($Query)-1]['sub'] ;
}
function tbsdb_myarray_fetch(&$Rs,$RecNum) {
  if($RecNum==1) {
    $x = reset($Rs) ;
  } else {
    $x = next($Rs) ;
  }
  if ($x===False) {
    return False ;
  } else {
    return array('val'=>$x) ;
  }
}
function tbsdb_myarray_close(&$Rs) {
}
By: peirgwnael
Date: 2004-01-14
Time: 23:04

Re: dev and block syntax

The new manuel is better i think.
I'm sory but it doesn't work (certaindlu due to my skills).
Could you give me the code you used (php and html) ?
By: Skrol29
Date: 2004-01-15
Time: 01:49

Re: dev and block syntax

PHP :
<?

include_once("tbs_class.php") ;

$col_lst = array() ;
$col_lst[] = array('FirstName'=>'Peter','LastName'=>'Littlesmith','Childs'=>Array('Bill','Sue')) ;
$col_lst[] = array('FirstName'=>'John','LastName'=>'Smilalot','Childs'=>Array('Greg','Loana')) ;
$col_lst[] = array('FirstName'=>'Henry','LastName'=>'Happyman','Childs'=>Array('Ben','Jenny')) ;

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate("test_subarray.htm") ;

$TBS->MergeBlock('b_main',$col_lst) ;
$TBS->MergeBlock('b_sub' ,'myarray','%p1%') ;

$TBS->Show() ;

function tbsdb_myarray_open(&$Source,&$Query) {
    global $col_lst ;
    return $col_lst[intval($Query)-1]['Childs'] ;
}
function tbsdb_myarray_fetch(&$Rs,$RecNum) {
    if($RecNum==1) {
        $x = reset($Rs) ;
    } else {
        $x = next($Rs) ;
    }
    if ($x===False) {
        return False ;
    } else {
        return array('val'=>$x) ;
    }
}
function tbsdb_myarray_close(&$Rs) {
}

?>

HTML :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p align="center"><strong><font color="#003399" size="3">Test sub-array</font></strong></p>
<table border="1" align="center" cellpadding="0" cellspacing="0">
  <tr bgcolor="#CCCCCC">
    <td width="100"><strong>Fiest Name</strong></td>
    <td width="100"><strong>Last Name</strong></td>
    <td width="100"><strong>Childs</strong></td>
  </tr>
  <tr>
    <td>[b_main.FirstName;block=tr]</td>
    <td>[b_main.LastName]</td>
    <td><table width="100%" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td>[b_sub.val;block=tr;p1=[b_main.#]]</td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
By: peirgwnael
Date: 2004-01-17
Time: 13:26

Re: dev and block syntax

i undertsand now.
thanks a lot.