Categories > TinyButStrong general >

Merging is not passing html characters

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Peter
Date: 2012-07-12
Time: 20:57

Merging is not passing html characters

I recently updated TBS from an old version, and some of my code passes html through variables as such:
$a="<option ....</option>";
when I upgraded to the latest TBS $a is now merged as
&lt;option .... &lt;/option&gt;
so some of my pages don't render properly
can someone tell me why this happens and how I might fix it
(preferably without changing my entire code base
Thanks
By: Skrol29
Date: 2012-07-12
Time: 22:26

Re: Merging is not passing html characters

Hi Peter, what was the old version, what is the new one ?
By: Peter
Date: 2012-07-12
Time: 22:37

Re: Merging is not passing html characters

old - 1.8.1
merging using:
$TBS = new Template;
$TBS->LoadTemplate() ;
$TBS->MergeBlock();
echo($TBS->Show());
new - 3.7 or 3.8
merging using
$TBS = new clsTinyButStrong;
$TBS->LoadTemplate() ;
$TBS->MergeBlock();
echo($TBS->Show());
By: Skrol29
Date: 2012-07-12
Time: 23:30

Re: Merging is not passing html characters

version 1.8.1 ! Woaw !

By default, TBS does an HTML conversion on data that is merged in the template.
You can change that by calling LoadTemplate() with an extra parameter which is the target charset (HTML by default).

If you code $TBS->LoadTemplate('my_template.html', false);
then there will be no data conversion.
See http://www.tinybutstrong.com/manual.php#php_loadtemplate

The other solution is to change the string conversion for chosen TBS fields, using parameter "strconv" (or "htmlconv" for versions prior tor 3.8)
See http://www.tinybutstrong.com/manual.php#html_field_prm_strconv

Don't forget that data can also be escaped to prevent from TBS injection.
See http://www.tinybutstrong.com/manual.php#html_field_prm_protect
By: Peter
Date: 2012-07-13
Time: 01:05

Re: Merging is not passing html characters

Perfect.
Yes 1.8.1 - we have some modules that are almost 10 years old and even though we have used newer tbs classes in parts of our solution - the old stuff never got changed.
Now that I am stuck with modifying some of these old modules - I am running into these little gotchas all the time.
Thanks for the prompt help!
TBS is a great tool!