Categories > TinyButStrong general >

Event functions

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Jorge
Date: 2004-03-01
Time: 17:05

Event functions

Hi,

I repreduced with sucess your   Event functions example when use a
array like
$data_array[] = array('res_name'=>'Marie',  'res_score'=>300, 'res_date'=>'2003-01-10') ;

But when I use a SQL database, like:

$query = "SELECT res_name,res_scrore, res_date";
       
$query .= " FROM mydatabase";

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('exemple1.htm') ;

$TBS->MergeBlock('b1',$cnx_id,$query) ;
$TBS->Show() ;

I get the following error:
TinyButStrong Error (Array value): Can't merge [b1.level] because there is no key named 'level'. This message can be cancelled using the 'noerr' parameter.

HTML side is exactly like in your example on your site
[b1.res_name;block=tr;onsection=m_event_b1]
[b1.level;htmlconv=no]

I've tryed something like [b1.level] or even [var.level], but doesn't work.

So how to display a new var when data is not defined into the SQL array?
By: Skrol29
Date: 2004-03-01
Time: 17:18

Re: Event functions

Hi,

Try with this extra line at the end of the event function m_event_b1():
if (!isset($CurrRec['level'])) $CurrRec['level'] = '(default)' ;
By: Jorge
Date: 2004-03-02
Time: 11:19

Re: Event functions

Seems to have same error:

TinyButStrong Error (Array value): Can't merge [blk1.level] because there is no key named 'level'. This message can be cancelled using the 'noerr' parameter.

Here's my HTML code "main.htm"

<table width="500" border="0" align="center" cellpadding="2" cellspacing="0">
  <tr>
<td valign="top">
    <p>[blk1.date1;onsection=sample]<br>
      [blk1.date2;block=table]<br>
      [blk1.date3]<br>
      [blk1.date4]</p>
    <p>[blk1.level;htmlconv=no] HELLO</p>
    <p> -------- </p></td>
  </tr>
</table>

And my PHP code: "main.php"


<?

include_once("tbs_class.php") ;
require("cnx_mysql.inc.php"); // Ouverture BD
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('main.htm') ;

function sample($NomBloc,&$CurrRec,&$DetailSrc,$RecNum) {
$CurrRec['level'] = 'super ça marche' ;
if (!isset($CurrRec['level'])) $CurrRec['level'] = '(default)' ;
}

$query = "SELECT date1, date2, date3, date4 FROM mydatabase";
// field "level" doesn't exist on 'mydatabase'

$TBS->MergeBlock('blk1',$cnx_id,$query) ;
mysql_close($cnx_id) ;


$TBS->Show() ;

?>


Does somebody have the same error?
By: Skrol29
Date: 2004-03-02
Time: 11:26

Re: Event functions

Ok, I see the problem.
Parameter 'onsection' must be in the same tag as parameter 'block'.
That is because 'onsection' is a Block parameter.
By: Jorge
Date: 2004-03-02
Time: 11:41

event function it works

Super ça marche!!!!!!!!!!!!!! Meeeeeeeeeeeeeerci!! si si..
ça fait juste 2 semaines que j'essaye de trouver d'ou ça viens...d'ou le fait que j'ai repris tes exemples.


Thanks, it works !!

Correct line is so:

blk1.date1;onsection=sample;block=table]<br>
  [blk1.date2]<br>
  [blk1.date3]<br>
  [blk1.date4]</p>
<p>[blk1.level;htmlconv=no] HELLO</p>

and doesn't need
if (!isset($CurrRec['level'])) $CurrRec['level'] = '(default)' ;
at the end


By: Cícero Raupp Rolim
Date: 2004-08-17
Time: 22:00

Re: event function it works

Yes!


Meu sistema funcionou! Muito bom esta classe!


O Brasil esta aderindo a este poderoso template!