previousHTML_Template_IT::loadTemplatefile() (Previous) (Next) HTML_Template_IT::parseCurrentBlock()next

View this page in Last updated: Sun, 18 Oct 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

HTML_Template_IT::parse()

HTML_Template_IT::parse() – Parsed einen Block

Synopsis

require_once 'HTML/Template/IT.php';

boolean HTML_Template_IT::parse ( string $block = "__global__" , boolean $flag_recursion = = false )

Description

Führt alle Ersetzungen am gegebenen Block durch und fügt das Resultat an die bereits durchgeführten Ersetzungen des gleichen Blocks an.

Parameter

  • string $block - Der Name des zu parsenden Blocks. Wenn der Parameter nicht gesetzt ist, wird das gesamte Template geparsed.

  • boolean $flag_recursion - Wird nur intern verwendet und kann deshalb ignoriert werden.

Return value

boolean - Gibt TRUE zurück wenn keine Platzhalter ersetzt wurden, andernfalls FALSE oder IT_Error.

Example

Das Template cvsnames.tpl.htm

<html>
 <table>
<!-- BEGIN row -->
  <tr>
   <td>
    {CVS_USERNAME}
   </td>
   <td> 
    {REALNAME}
   </td>
  </tr>
<!-- END row -->
 </table>
</html>

Das Script

<?php
  
require_once "HTML/Template/IT.php";

  
$data = array
  (
    
"0" => array("cvs_username" => "pajoye"
                 
"realname" => "Pierre-Alain Joye"),
    
"1" => array("cvs_username" => "dsp",
                 
"realname" => "David Soria Parra")
  );

  
$tpl = new HTML_Template_IT("./templates");

  
$tpl->loadTemplatefile("cvsnames.tpl.htm"truetrue);

  foreach(
$data as $name) {

     
$tpl->setVariable("CVS_USERNAME"$name["cvs_username"]);
     
$tpl->setVariable("REALNAME"$name["realname"]);

     
$tpl->parse("row");
  }

  
// show() parses the __global__ block and
  // print the output
  
$tpl->show();

?>

Throws

Possible PEAR_Error values
Error code Error message Reason Solution
IT_BLOCK_NOT_FOUND " Cannot find this block block " Der angegebene Block existiert im geladenen Template nicht. Überprüfen Sie, ob der Blockname richtig geschrieben ist.

Note

This function can not be called statically.

previousHTML_Template_IT::loadTemplatefile() (Previous) (Next) HTML_Template_IT::parseCurrentBlock()next

Download Documentation Last updated: Sun, 18 Oct 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.