Location: PHPKode > scripts > Easy Template > example1.php

// Create the template object
$template = new Template("example1.html");

// Replace the tags with real data
$template->replaceTag("NameTag", "John Doe");
$template->replaceTag("TextFieldTag", "This is a textbox value");

// Template::getHTMLChecked returns selected="selected" if the value passed
// in is true, "on", "selected", "checked", "yes", "y", "true", or "t"
$template->replaceTag("CheckedTag", Template::getHTMLChecked(true));

NOTE: you cannot execute any PHP code in a template file by default.
That means that server side includes are not possible in templates as is.

One way we could show more than one page if we needed to and
emulate a server side include would be to use the following:


Or you could replace a tag with the code from another template:

  $templateMain->replaceTag("HeaderTag", $templateHeader->getPage());
  $templateMain->replaceTag("FooterTag", $templateFooter->getPage());

Or we could grab executed PHP code from a web page! Executed code
can then be used to replace a tag in a template file:

  $template->replaceTagFromWeb("TagName", "http://google.finderg.com");

Or we can load data directly from any file to replace a tag instead!
$template->replaceTagFromFile("JavaScriptTag", "example1.js");

// Show the page
Return current item: Easy Template