Categories > TinyButStrong general >

LoadTemplate - More than One?

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

LoadTemplate - More than One?

Well, I started using tinybutstrong, and love it, but I have run into a problem.  Is it possibly with TBS to load more than one template at a time?   I do a LoadTemplate, another LoadTemplate, and only the last one actually shows when I use a Show().

Any help would be trully appreciated.
By: Skrol29
Date: 2004-01-22
Time: 02:50

Re: LoadTemplate - More than One?

Hi Sar-Ca-Sm :)

Yes it is possible to load several templates at a time.
$TBS1 = new clsTinyButStrong ;
$TBS2 = new clsTinyButStrong ;
I can detail if needed.
By: SarCaSM
Date: 2004-01-22
Time: 03:02

Re: LoadTemplate - More than One?

Hmmm, I tried that, or so I think I did.  Possible for you to detail that one for me? 
By: Skrol29
Date: 2004-01-22
Time: 11:37

Re: LoadTemplate - More than One?

Ok.

When you write
$TBS = new clsTinyButStrong ;
it creates a new object variable named $TBS which is an new 'instance' of the class 'clsTinyButStrong'.
Those are technical terms of Oriented Object Programing.

When you code $TBS->LoadTemplate(...) or $TBS->MergeBlock(...), this changes the value of the property $TBS->Source.
$TBS->Source is a kind of sub-variable attached to the variable $TBS.

When you code $TBS->Show(), this merge automatic fields and then performs
  echo ($TBS->Source) ;

Now, when you code:
$TBS1 = new clsTinyButStrong ;
$TBS2 = new clsTinyButStrong ;
it creates two objects variables (instances), with their own sub-variables (properties). Therefore $TBS1->Source and $TBS2->Source are two different values.

You can play with that. Loading the first template in $TBS1, and the other in $TBS2. Merging blocks as needed on each instance.
Before the end, you can manage the two contents as needed.

Example : $TBS1->Source = $TBS1->Source.$TBS2->Source ;
This adds the result of $TBS2 afed the result of $TBS1.

Or:
$TBS1->MergeBlock('subtpl','text',$TBS2->Source) ;
This merges the block named 'subtpl' placed in $TBS1 with the result of $TBS2.

A last tip: you can call the $TBS->Show() method without displaying the result. See the Render property in the manual for more details.
By: SarCaSM
Date: 2004-01-22
Time: 20:02

Re: LoadTemplate - More than One?

Awesome, thank you, works perfectly.