Categories > TinyButStrong general >

List all fields

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Zhilchenko
Date: 2012-06-08
Time: 06:56

List all fields

Hello.
How can I see all variables in template with TBS?

Just now I'm trying to do it with TplVars but without success.
By: Zhilchenko
Date: 2012-06-08
Time: 07:33

Re: List all fields

Ok, I think I get it.

  $TBS->LoadTemplate($template);

  foreach ($TBS->TplVars as $key => $value) {
    $TBS->VarRef[$key] = $my_values[$key];
  }

Remark "Parameter tplvars works only with onload automatic fields" in manual confuses me. It works with 'onshow' too:
[onshow.Name;tplvars;]
By: Skrol29
Date: 2012-06-08
Time: 11:43

Re: List all fields

> Remark "Parameter tplvars works only with onload automatic fields" in manual confuses me. It works with 'onshow' too:

Parameter "tplvars" is used to define new Template Variables. Is is taken in account only with [onload] field. That is you can create Template Variables at the template side only with [onload].

Nevertheless, you can display Template Variables at anytime: [onshow..tplvars.my_var]

[onshow.Name;tplvars] is the same as [onshow.Name] and it displays the global variable $Name.

By: Zhilchenko
Date: 2012-06-09
Time: 11:18

Re: List all fields

Forgot to say I'm using OpenBTS with .docx.

When I put
[onshow..tplvars.my_var]
in template I can't see my_var in $TBS->TplVars and on Show() I getting an error:
TinyButStrong Error in field [onshow..tplvars.my_var...]: property TplVars doesn't have any item named 'my_var'.
By: Skrol29
Date: 2012-06-09
Time: 20:52

Re: List all fields

> Forgot to say I'm using OpenBTS with .docx.

The feature is the same, whenever your using HTML, DOCX, ODT, ...

> in template I can't see my_var in $TBS->TplVars and on Show() I getting an error:

It assumes you've defined an items in $TBS->TplVars using
$TBS->TplVars['my_var'] = 'something';
or using
[onload.;tplvars;my_var=something]
By: Zhilchenko
Date: 2012-06-10
Time: 07:07

Re: List all fields

Can I list all variables defined in template?

I want generate form with all vars for user.
By: Skrol29
Date: 2012-06-11
Time: 01:28

Re: List all fields

>Can I list all variables defined in template?

They are stored in $TBS->TplVars.

The list of names can be displayed using [onshow..tplvars;ope=list].