Categories > TinyButStrong general >

Imbedded apostrophes in output

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Tom
Date: 2011-03-25
Time: 17:02

Imbedded apostrophes in output

I have a data field with names that may include an imbedded apostorphy.  I get an error when the field is merged.
TinyButStrong Error : can't found the end of the tag '[blk1.var_site_link;if !='';th...'.

I use the mysql addslashes function when i store the field in the database and I created a user function to strip the slashes when the field is displayed. 
I've read and tried several of the solutions I've found here in the forum but none seem to fit my needs.  When I use htmlconv=esc with the field, i end up with two '' apostropes in the output, and extraneous data in the html output.
I would appreciate any help I can get.   THANKS
Error message when page is loaded:
TinyButStrong Error : can't found the end of the tag '[blk1.var_site_link;if !='';th...'.

PHP code that loads the template:
$PageSize = 8;


$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('scl_index_display.html');

// Merge the block by page
$TBS->PlugIn(TBS_BYPAGE,$PageSize,$PageNum,$RecCnt); // Next block will be merged suing By-Page mode.
$RecCnt = $TBS->MergeBlock('blk1','mysql',$club_search);


// Merge the Navigation Bar
$TBS->PlugIn(TBS_NAVBAR,'nv','',$PageNum,$RecCnt,$PageSize);

$TBS->Show();

Portion of template where the error is displayed:
<tr>
    <td class="state" colspan="3">[blk1.state_name;block=tr;headergrp=state_name]</td>
</tr>
<tr>
    <td class="city" colspan="3">[blk1.var_city;block=tr;headergrp=var_city;ondata=strip_slashes]</td>
</tr>
<tr>
    <td class="data" >[blk1.var_name;htmlconv=esc;block=tr;headergrp=var_name;ondata=strip_slashes]
            <br />[blk1.var_address;htmlconv=esc;ondata=strip_slashes],&nbsp;[blk1.var_post_code]
            <br />[blk1.var_phone_number;onformat=get_phone]</td>
     <td class="data" >Type:&nbsp;[blk1.var_category;onformat=get_category]
        <br />Bar:&nbsp;&nbsp;[blk1.var_bar;onformat=get_bar]
        <br />Food:&nbsp;[blk1.var_food;onformat=get_food]</td>
    <td class="data" ><a href="scl_display_map.php?address=[blk1.var_address]&city=[blk1.var_city]&state=[blk1.var_state_code]&zip=[blk1.var_post_code]">Directions</a>
          <br /><a href="scl_var_reviews.php?var_id=[blk1.var_id]">Reviews</a>:&nbsp;[blk1.var_review_count]&nbsp;<img src=[blk1.var_review_average;onformat=review_image] align="absmiddle">
        <br />[blk1.profile_id;if [blk1.profile_id]!='';then <a href="http://scl_profile_display.php?profile=[blk1.var_id]">var Profile</a>;else <a href="scl_nolink.php?type=profile&var=[blk1.var_name]">var Profile</a>;noerr]&nbsp;
        &nbsp;[blk1.var_site_link;if [blk1.var_site_link]!='';then <a href="http://[blk1.var_site_link]" target="_blank">var Site</a>;else <a href="scl_nolink.php?type=site&var=[blk1.var_name]">var Site</a>;noerr]</td>
</tr>


Sample HTML output:

Rick''s 
address, zipcode
phone number Type: type
Bar:  bar
Food: food
Reviews: 0   Profile;noerr]   [blk1.var_site_link;if !='';then  var Site;else   var Site








By: Skrol29
Date: 2011-03-26
Time: 01:56

Re: Imbedded apostrophes in output

Hi Tom,

Parameter "htmlconv=esc" is done for those kind of problem. But since this option makes TBS escape the quotes in the inner value, it assumes that you've delimited an expression with quotes.
Thus you should replace:
else <a href="scl_nolink.php?type=site&var=[blk1.var_name]">var Site</a>
with
else '<a href="scl_nolink.php?type=site&var=[blk1.var_name;htmlconv=esc]">var Site</a>'

Nevertheless less, you can see that such a field in an URL can make an invalid URL if var_name can have strange characters.
You may also try with [blk1.var_name;htmlconv=url]

If the if/then/else expression is too complicated you can consider using conditional sections in the block.
By: Tom
Date: 2011-03-26
Time: 02:21

Re: Imbedded apostrophes in output

Thank you so much.  That worked like a charm.    I hadn't gotten to the point of testing with a real url yet, so you probably saved me some more hair pulling as well.
I removed the htmlconv=esc from the name fields which got rid of the double '' quotes within the name, and added the single ticks and htmlconv=url to the url field and it looks like its working fine.
Thanks again for your help and quick response.