Categories > TinyButStrong general >

php form action display in template

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: edavison
Date: 2008-04-28
Time: 06:18

php form action display in template

I am using a template structure I got from the examples to display a "frame" around an input file using the following:

<div id="box_center">
[onload;file=[var.tmpl_article];getbody]
</div>

if (isset($_GET['art'])) {
        $art = $_GET['art'];
} else {
        $art = "default";
}

$tmpl_article = $art.".html";

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

...

$TBS->Show() ;

Now, I have a form in one of those .html files that calls a PHP file to do the action (insert into a database).

How do I get the PHP output into this template?
By: Skrol29
Date: 2008-04-28
Time: 11:30

Re: php form action display in template

Hello,

I'm not sure to understand well your last question.

The subtemplates you have should have links to PHP files. If you have a global main template merged with a main script (the ones you've given above), then to good idea is to use the main script to do sub actions.

Like this :
if (isset($_GET['art'])) {
        $art = $_GET['art'];
} else {
        $art = "default";
}

if ($art=='insert') {
  ...
} elseif ($art=='newrecord') {
  ...
}

$tmpl_article = $art.".html";

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

...

$TBS->Show() ;
By: edavison
Date: 2008-04-28
Time: 15:49

Re: php form action display in template

I guess I was not very clear.  I do have that if ... elseif block in my code that you reference.

My question is that one of the .html pages is a form.  It has a form action of a .php file.  If I put the .php file into the $TBS->LoadTemplate call then it would not execute the .php actions but rather render the PHP code into html.

How do I execute the php and still get its output into my templates?  Or are you saying that my form action should be my index.php file and the if ... else section and make the index.php file do ALL of the work?  Or should I add the template code and another $TBS->LoadTemplate call to me form action .php file?
By: edavison
Date: 2008-05-01
Time: 17:50

Re: php form action display in template

Anyone?

Do I need to do the whole template thing in my form action .php file?  Or do I need to try to do ALL of the work for the entire website in index.php?

By: Pirjo Posio
Date: 2008-05-01
Time: 19:54

Re: php form action display in template

I don't have time to get deeper into this, but Isn't the online example "Execute another script" close to what you have in mind?
By: Skrol29
Date: 2008-05-02
Time: 11:21

Re: php form action display in template

Hi,

Several architectures are possible.

With your first post, we can say that your architecture is about to be one index.php file for several templates to display. This can be a good solution, it's up to you.

With such an architecture, it's normal that the the index.php is also executing all actions which are specific to the template to display.

Actions for the form should be processed by the index.php file, somewhere in the if...the...else control structure. It can be directly coded there, or if the action is quite a piece of code, it can be stored into another script which is called with include().