By: whl
Date: 2005-01-27
Time: 05:49
|
merge VAR doesn't show
I have a script-A that merge with tmpl-A. In tmpl-A, embeded script-B and then script-B includes script-C.
Script-C basically merge and get the source of tmpl-C using TBS->Source. Subsequently, it pass the source to script-B that merge with tmpl-B for final output.
Problem is in script-C where i have a global variable varAAA="ABC" and when i merge with tmpl-C, the source shows [var.varAAA] instead of "ABC". However when I echo "$varAAA" from script-C it did shows "ABC" confirming that the variable is valid.
How do i go about solving this prolem. Pls help.
|
By: Skrol29
Date: 2005-01-27
Time: 13:39
|
Re: merge VAR doesn't show
Hello,
This is probable because $varAAA is not a global variable.
You maybe have coded it as a global variable but scripts exexuted using parameter 'script=' don't have a global scope. They have the same scope as a user function.
Try to add
at the beginin or your sub-script and it should work.
|
By: whl
Date: 2005-01-28
Time: 04:00
|
Re: merge VAR doesn't show
Hi Skrol,
Adding global $varAAA to subscript script-B or script-C or both doesn't help at all.
Currently, I have an alternative solution to it by using TBS->MergeField('new_merge_var',array('varAAA'=>$varAAA)) and it works fine.
Just wondering if this problem was due to TBS as I noticed TBS->Source returned [var.varAA]
I also make another test by replacing TBS->Source with TBS->Show() in script-C and to my surprise, it did merge and display perfectly.
I'm using tbs-2.0
Hope my feedback will help... One last word, really fall in love with TBS :)
|
By: Skrol29
Date: 2005-01-28
Time: 10:46
|
Re: merge VAR doesn't show
> I noticed TBS->Source returned [var.varAA]
Ok, that is the clue!
When a data is merged with the template, TBS replaces '[' with '[' for security reason. This security can be avoid using parameter 'protect=no' ; This rotection is not activated for file inclusion but it is for script inclusion.
So you should just add parameter 'protect=no' to you TBS tag.
[onload;script=script-B.php;protect=no]
...
[onload;script=script-C.php;protect=no]
|
I will thing to see if it's more coehrent to have protection desactivated by default with parameter 'script', like it is for parameter 'file'.
|
By: whl
Date: 2005-02-01
Time: 06:36
|
Re: merge VAR doesn't show
Thank you so much Skrol... works with flying colors.
Your support worth a million dollars and TBS deserves the best template engine title. :)
|
|
Posting in progress.
Please wait...
|