Categories > TinyButStrong general >

Dynamic include

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: SoftExpert
Date: 2006-06-08
Time: 11:27

Dynamic include

Hi,

Is it possible to have this behavior, and if it is, then how to do it?

On "code" side
$vars['styles'] = 'path to a file'; // this could change anytime


On template side:

include the file specified by the $vars['styles'] value

I tried both
1.
[onshow;file=vars.styles;htmlconv=no]

and
2.
[onload;file=vars.styles;htmlconv=no]


with no result. This error is given:
TinyButStrong Error in field [onshow...] : the file 'vars.styles' given by parameter file is not found or not readable

or
TinyButStrong Error in field [onload...] : the file 'vars.styles' given by parameter file is not found or not readable


Also, the loaded file could have some other fields/blocks ...


Please, help!
By: Skrol29
Date: 2006-06-08
Time: 11:55

Re: Dynamic include

Hi,

You can have this by embeddings TBS tags.
[onshow;file=[var.styles]]
By the way: "htmlconv=no" is by default when using parameter "file".

Note that embeddeds TBS tags are available only for some parameters.
http://www.tinybutstrong.com/support.php#faq_embedvar
By: Skrol29
Date: 2006-06-08
Time: 12:00

Re: Dynamic include

If the subtemplate may contain TBS blocks to merge, then it's better to use [onload] instead of [onshow].

When using [onload], just take care that embedded [var] fields are well defined before calling LoadTemplate().
By: SoftExpert
Date: 2006-06-08
Time: 13:55

Re: Dynamic include

Thanks for the reply!
I handled it some other way: I loaded each dynamic part an I got the Source property; finally I merged those parts in the main template with MergeField ...

Seems to be just a little bit slow, though ...
Is there a faster way?
By: Skrol29
Date: 2006-06-08
Time: 19:46

Re: Dynamic include

> Is there a faster way?

It shouldn't be that slow. It maybe comes from your usage of MergeField() is you use it too much. Don't forget that MergeField() can merge several fields in one call.