Categories > TinyButStrong general >

LoadTemplate suggestion?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: SarCaSM
Date: 2004-03-09
Time: 02:03

LoadTemplate suggestion?

Skrol,  I commonly load multiple templates in a single page request.  I was thinking it would be nice to do something like the following, you have two TBS instances $TBS1 and $TBS2, then load a template per the usual using $TBS and then loading the next with $TBS2 and the combining the sources and then loading another template and combining and so on and so on, have an extra agruement in LoadTemplate where you specify the original TBS instance.  For instance, instead of

$TBS->LoadTemplate('template.html');
$TBS2->LoadTemplate('nextTemp.html');
$TBS->Source .= $TBS2->Source;
$TBS2->LoadTemplate('nextTemp2.html');
$TBS->Source .= $TBS2->Source;

there would be something like

$TBS->LoadTemplate('template.html');
$TBS2->LoadTemplate('nextTemp.html',$TBS);
$TBS2->LoadTemplate('nextTemp2.html',$TBS);

Just a thought I had.
By: SarCaSM
Date: 2004-03-09
Time: 02:06

Re: LoadTemplate suggestion?

Whoops, just realized there is already an optional second arguement for LoadTemplate(), but still hopefully you get the idea.  It would be useful to me as the current way is pretty repetitive.
By: Skrol29
Date: 2004-03-09
Time: 15:15

Re: LoadTemplate suggestion?

Hi SarCaSM,

I know several TBS instances can be usefull, but in your case, Why don't you simply use only one instance, and load/past template sources one by one into a string variable?
Like this:
$src = '';
$TBS->LoadTemplate('template1.htm');
$src .= $TBS->Source;
$TBS->LoadTemplate('template2.htm');
$src .= $TBS->Source;
...
$TBS->Source = $src ;

May be an extra parameter of LoadTemplate() can tells that the template source is to be added no to erase old source.
By: SarCaSM
Date: 2004-03-09
Time: 20:57

Re: LoadTemplate suggestion?

Ahh, I for some reason or another was under the impression that it required that another instance of TBS be made.  weird.  But yea, the having an arguement to not erase source and to add to it instead would be a really nice option.
By: SarCaSM
Date: 2004-07-28
Time: 16:37

Re: LoadTemplate suggestion?

I know its been a while since this was asked for, but could this possibly be included in a future version of TBS? Possibly TBS2?  it would be a tremendous help to me, and I'm sure others as well.  More like the having an extra parameter for LaodTemplate() that can tell the template source if it is to be added to or erased.
By: Skrol29
Date: 2004-07-28
Time: 23:42

Re: LoadTemplate suggestion?

There is already extra parameters planed for LoadTemplate() in v2.
But nothing fixed yet.
I will study for a smart way to add this feature in a next version.