Categories > TinyButStrong general >

few questions

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: surfweb
Date: 2010-12-22
Time: 13:13

few questions

Hello everyone.

I just started programming and I found this very interesting project.

My code:

mypage.php

require_once( (version_compare(PHP_VERSION, '5')>=0) ? ClassPath . 'tbs_class_php5.php' : ClassPath . 'tbs_class.php');   
    if (!isset($_SERVER)) $_SERVER=&$HTTP_SERVER_VARS ;

function hello(){
echo "hello";
}

$TBS = new clsTinyButStrong;  
$header = TPL_DIR . '/header.php';
$TBS->LoadTemplate(TPL_DIR . 'mypage.html');
$TBS->MergeField('myhello','hello',true);
$footer = TPL_DIR . '/footer.php';
$TBS->Show();

header.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>mypage</title>
<link rel="stylesheet" type="text/css" href="tpl/css/style.css" media="screen"  />
</head>
<body>

footer.php

</body></html>

mypage.html
[onshow.header;script=[val];subtpl]
<div id="mypage">
[myhello.*]
</div>
[onshow.footer;script=[val];subtpl]

I have this problem:

function hello(); is shown before doctype instead of the body, why?

ciao
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>mypage</title>
<link rel="stylesheet" type="text/css" href="tpl/css/style.css" media="screen"  />
</head>
<body>
</body></html>

I hope someone can help me understand my mistakes

sorry for my English but not speak it very well!
By: Skrol29
Date: 2010-12-22
Time: 19:26

Re: few questions

> function hello(); is shown before doctype instead of the body, why?

When you add [onshow.header;script=[val];subtpl] in the template, you ask to run the header.php file as a PHP script, but the subtpl "parameter" has no effect on the HTML which is
directly coded in the PHP file. It can catch only HTML sent by output PHP commands like echo().

You should replace [onshow.header;script=[val];subtpl] with [onshow.header;file=[val]]
And [onshow.footer;script=[val];subtpl] with [onshow.footer;file=[val]].
By: surfweb
Date: 2010-12-23
Time: 10:33

Re: few questions

Thanks very much Skrol29!!