Categories > TinyButStrong general >

functions for generating html tags to be used in template html but not as value.

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Rock Lee
Date: 2008-03-13
Time: 10:30

functions for generating html tags to be used in template html but not as value.

I have a few php functions that generates html tags depending on the POST results and others depending on queried results of a sql database.

When I use MergeField to call the function, the web page shows the html codes (like when it's inside the <pre> tag). When I look into the source code it shows the tags as

&lt;td&gt;|&lt;/td&gt;<br /> 

& lt;td& gt;|& lt;/td& gt;<br /> (space added in case the previous line doesn't show)

Am I using MergeField wrong? Below are my codes.

PHP file:
function quotelist() {

    $qsearch .= "<div align=\"center\"><form name=\"QuoteSearch\" action=\"$_SERVER[PHP_SELF]\" method=\"POST\">\n<p class=\"smalltext\">";
    $qsearch .= "    <input class=\"qbsearch\" type=\"text\" name=\"Keywords\"";

    if (isset($_POST[Keywords])) {
        $qsearch .= " value=\"$_POST[Keywords]\"";
    } elseif (isset($_GET[Keywords])) {
        $qsearch .= " value=\"$_GET[Keywords]\"";
    }

    $qsearch .= " size=\"40\">\n";
    $qsearch .= "    <input class=\"button\" type=\"submit\" value=\"Find It\"><br>\n";
    $qsearch .= "Match:\n";

    $qsearch .= "    <input type=\"radio\" name=\"searchchoice\" value=\"1\"";
    if ( ($_POST[searchchoice] == 1) || ($_GET[searchchoice] == 1) || (!isset($_POST[searchchoice]) && !isset($_GET[searchchoice])) ) { $qsearch .=  " CHECKED"; }
    $qsearch .= ">Any word\n";

    $qsearch .= "    <input type=\"radio\" name=\"searchchoice\" value=\"2\"";
    if ( ($_POST[searchchoice] == 2) || ($_GET[searchchoice] == 2) ) { $qsearch .=  " CHECKED"; }
    $qsearch .= ">All words\n";

    $qsearch .= "    <input type=\"radio\" name=\"searchchoice\" value=\"3\"";
    if ($_POST[searchchoice] == 3 || $_GET[searchchoice] == 3 ) { $qsearch .=  " CHECKED"; }
    $qsearch .= ">Exact phrase\n";

    $qsearch .= "    <input type=\"hidden\" name=\"doSearch\" value=\"doSearch\">\n";
    $qsearch .= "</p></form></div>\n";

    return $qsearch;
}

.
.
.
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('template.html');
$TBS->MergeField('blk','quotelist');
$TBS->Show() ;

HTML file:
<html><body>
    [blk.title]
</body></html>

Can anyone tell me where I have gone wrong please? Thanks in advance.
By: TomH
Date: 2008-03-13
Time: 11:34

Re: functions for generating html tags to be used in template html but not as value.

Hi

Try
<html><body>
[blk.title;htmlconv=no]
</body></html>

HTH,
By: Rock Lee
Date: 2008-03-14
Time: 09:50

Re: functions for generating html tags to be used in template html but not as value.

Thanks TomH!

I got another question and I am not sure if I should start a new thread. So here goes...

I am trying to call content from a text file in my php file, I assigned

$includetext = "/legal/terms.inc';

and in my HTML file, I use

[var.includetext]


But instead of displaying the content of the terms.inc file, the web page displayed '/legal/terms.inc' as the string itself.

How can I make TBS call out the content of the text file with all its html formatting?

Appreciate if you (or anyone else) can help again. Thanks in advance.

By: TomH
Date: 2008-03-14
Time: 13:33

Re: functions for generating html tags to be used in template html but not as value.

You need to plan on using the PHP help file to learn your way through some of this -- download it to your computer for handy reference -- it will really help you as you learn PHP

From PHP, use the file_get_contents() function it reads an entire file into a string for you.

$includetext = file_get_contents("/legal/terms.inc");

Don't forget the htmlconv=no parameter in the template
By: ege
Date: 2008-03-16
Time: 14:18

Re: functions for generating html tags to be used in template html but not as value.

You might as well do this:
[onload;file=[var.includetext]]
which preserve any html within the file.