home    download    forum    manual    awards    faq    bugs    links

TemplatePower manual




Arabic
Deutsch
Dutch
English
Italian
Portuguese (Brazilian)
Russian
Spanish


* Not fully translated yet.




Looking for the manual in your language? Well, I need translators to translate the manual to any language. So, if you have some sparetime please sign up!

Just email to sign up:
rovel999_AT_codocad_DOT_com

If you have signed up you will receive more information about the translation.

assignInclude

(TP 2.0+)

Tell which file/content to include.

Description

assignInclude ( string includename, string filename/content, [const type] )


The default value of the parameter type is the constant T_BYFILE, in case the second parameter is a filename. If the second parameter for example is a variable with the content of a template, type should be set to T_BYVAR.
Example 1.
include.tpl
<html>
<head>
  <title>AssignInclude Example</title>
</head>
<body>
  <!-- INCLUDE BLOCK : header -->

  <!-- INCLUDESCRIPT BLOCK : content -->
</body>
</html>

myscript.php
<?php
include_once( "./class.TemplatePower.inc.php" );

$tpl = new TemplatePower( "./include.tpl" );
$tpl->assignInclude( "header", "./header.tpl" );
$tpl->assignInclude( "content", "./about.php" );
$tpl->prepare();

$tpl->printToScreen();
?>


Examples of the assignInclude function
$tpl->assignInclude( "header", "./header.tpl" );
$tpl->assignInclude( "content", $content, T_BYVAR );


Example 2.  Database Templates

<?php
  include( "./class.TemplatePower.inc.php");

 //connect to database
   $link = mysql_connect("host", "user", "passwd")
              or die("Could not connect");
     
  mysql_select_db("my_database") 
      or die("Could not select database");  

 //get database templates
   $qry = "SELECT base, header FROM templates";

  $result = mysql_query($qry);
  
  if( mysql_num_rows($result) > 0)
  {
      list($base, $header) = mysql_fetch_row($result);
  }
 
 //make a new TemplatePower object
  $tpl = new TemplatePower( $base, T_BYVAR );

 //assign include template by variable
  $tpl->assignInclude( "header", $header, T_BYVAR );
  $tpl->prepare();

 //print the result
  $tpl->printToScreen();
 ?>
 

 
CopyRights © 2001-2009 Ron. P.J. Velzeboer.