Categories > TinyButStrong general >

How to add a argument to an Event Function?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Marcelo
Date: 2010-05-14
Time: 16:44

How to add a argument to an Event Function?

function checa($BlockName,&$CurrRec,$RecNum, $pk = $p1000)
{         
         
          $q = mssql_query("SELECT fields FROM table WHERE fk = $CurrRec['field'] AND FK = $pk");
         
          if (mssql_num_rows($q) > 0)
          {
                   $CurrRec['check'] = 'checked';
          }else
          {
                  $CurrRec['check'] = '';
          }
    }

I just need to pass an value that isn't on this recordset, how can I do that?
By: Skrol29
Date: 2010-05-14
Time: 18:09

Re: How to add a argument to an Event Function?

Hi,

You cannot customize the event function calling syntax.
You have to use a global variable that you retrieve in your event function.

There is also an undocumented alternative (not tested yet):
function checa($BlockName,&$CurrRec,$RecNum,&$TBS) {
  ...
}
This syntax allows to use the $TBS object in the event function. That can be an idea to retrieve a custom parameter. For example $TBS->TplVars['p1000']
By: Marcelo
Date: 2010-05-14
Time: 18:36

Re: How to add a argument to an Event Function?

Thanks Skrol!

I used a global.


By the way, I tested the undocumented alternative, but I didn't worked.