HTML_Template_IT::parseCurrentBlock()

HTML_Template_IT::parseCurrentBlock() – Parsed den aktuell gesetzten Block

Synopsis

require_once 'HTML/Template/IT.php';

boolean HTML_Template_IT::parseCurrentBlock ( )

Description

Parsed den durch HTML_Template_IT::setCurrentBlock() gesetzten Block.

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);

  
// set the current block, which can now be used with parseCurrentBlock()
  
$tpl->setCurrentBlock("row"); 
  foreach(
$data as $name) {
     
// Assign data to the inner block

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

     
// parse the current set block
     
$tpl->parseCurrentBlock();
  }

  
// 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.