TinyButStrong - the PHP Template Engine
Categories > TinyButStrong general >

Starting with TBS

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Jonas
Date: 2012-08-29
Time: 10:33

Starting with TBS

Hello everybody,

I am new on this forum and I have just discovered TinyButStrong. I've tried to program some things, but it does not work. I have read the tutorials online and I am starting I would like to try the mini example showed below (I found at this URL : http://www.tinybutstrong.com/manual.php#php_mergefield) :

Mini examples:

Example 1:

(Html Template)     

<html>
  <body>
    [onshow.message]
  </body>
</html>

   
(Php Program)
<?php
    
  include_once('tbs_class_php5.php');
  $TBS = new clsTinyButStrong;
  $TBS->LoadTemplate('template.htm');

  $message = 'Hello';
  $TBS->Show();
   
(Result)

<html>
  <body>
    Hello
  </body>
</html>

I do not manage to get the good result, here is what my browser shows (exactly the code that I copied from the website into the file "template.htm") :

<html>
  <body>
    [onshow.message]
  </body>
</html>

Then I am not sure of how works a template, I just created a text file, renamed it template.htm (to fit the code) and edited and then copied the code in it.

Can anyone tell me why it does not work... (Maybe someone has a good tutorial where I could get explainations...)

Thank you very much by advance for any information that could help me out.





By: Skrol29
Date: 2012-08-30
Time: 00:08

Re: Starting with TBS

Hi Jonas,

You have to call the PHP file from your browser, not the template file.

In fact, your template file can have any name and any extension (.tpl, .txt, ...), you just have to mentionate it with LoadTemplate().

The principle of the template engine is this: it takes a template ;  it parse the template contents and replace placeholders with convenient data ; it provide or display the result.