Categories > TinyButStrong general >

Include with variables

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: boci
Date: 2004-04-14
Time: 22:08

Include with variables

Hi!
I have a little problem. I want to include a sub-template with variable,
for reusable template.
[tbs_include.onload;file=menu;tablename=menu_main]
[tbs_include.onload;file=menu;tablename=menu_send]

And: menu template:
the menu is [tablename]

It's possible?

Cow
By: Skrol29
Date: 2004-04-15
Time: 10:51

Re: Include with variables

Hi,

TBS can't select a Html table in a sub-template.
You have to have 2 sub_template, or to write your own custom function that found the proper Htlm table in a Html file. Then you can call this custom function from a TBS tag.
By: boci
Date: 2004-04-16
Time: 04:06

Re: Include with variables

I thin you not undertand what I want ;) (My english is very poor ;)

So I not want to select a table in a subtemplate, I only want add local variable into the sub template.
example
[tbs_include.onload;file=asd.php;subvariable=example1]
[tbs_include.onload;file=asd.php;subvariable=example2]

and I want to use the subvariable in the asd.php sub-template

Cow
By: RwD
Date: 2004-04-16
Time: 12:01

Re: Include with variables

why not use a global variable for that? just prefix then right and you don't get micxed up.

Or use an array with the values you want to pass like
$values['val1'] = 'lala';
$values['val2'] = 'lolo';
They are accessible like [var.values.val1]
but you cannot go any deeper then a 2 dimensional array.

I also think the above suggestions are the only way...
But your idea might be worth looking at for v2 I think.

Skrol, couldn't you convert everything inside the tbs markup tags into a local variable if it is not reckognized?
But, then make sure you can either turn this on or off, or have the debugging mention it was converted in case one writes an existing var wrong....
By: Skrol29
Date: 2004-04-16
Time: 12:16

Re: Include with variables

> but you cannot go any deeper then a 2 dimensional array.

Since 1.95 it should.

> Skrol, couldn't you convert everything inside the
> tbs markup tags into a local variable

I can very easylly add a global variable $tbs_CurrPrm which points on the array that contains parameters of the current TBS tag.
It costs one more TBS global variable, but it probably worths it.
What do you think?


By: RwD
Date: 2004-04-17
Time: 16:08

Re: Include with variables

I think that is good enough :D
That also helps in debugging I hope

But this will lead to usable custom variables for as far the names aren't used in tbs, right?

I haven't had to use something like that uptill now because I declared everything globally, but it would be a nice feature if you think it is ok...