On Mon, 21 Jan 2008 09:12:48 -0000, Anton Andrievskij <[EMAIL PROTECTED]> wrote:

I write this letter to ask about what the best idea about how to use the
PHPTAL engine with
the standard PHP site engine technology like this:

and so on...

I'm going to build index.html template and run it from index.php page, but then I have different code to be executed on different pages like login.php,
faq.php, subscribe.php and so on.

PHPTAL works best if you design your application using MVC pattern (separate data, application logic and presentation layers).

However, if you're looking for a simple approach:

You probably have index.php file with something like:
include "pages/$page.php"; // ofcourse $page should be throughly filtered to avoid security issues

Then change it to:

$phptal = new PHPTAL("templates/$page.html");
include "pages/$page.php";
echo $phptal->execute();

and inside page's php files (like faq.php) collect data in arrays or directly in $phptal object.

Instead of outputting everything instantly, e.g.:
  foreach($questions as $question) {echo '<h2>'.$question.'</h2>';}

just save data for later use in a template:
  $phptal->questions = $questions;

regards, Kornel

PHPTAL mailing list

Reply via email to