PHP Classes

File: example2.php

Recommend this page to a friend!
  Classes of Dmitry Levashov  >  YaTemplate  >  example2.php  >  Download  
File: example2.php
Role: ???
Content type: text/plain
Description: nested blocks example
Class: YaTemplate
Yet another template class
Author: By
Last change:
Date: 20 years ago
Size: 1,026 bytes
 

Contents

Class file image Download
<?php

include "YaTemplate_class.php";

$T = new YaTemplate();

$T->SetFile(array(main=>"main.html", tb=>"table2.html"));

$T->SetBlockTree("tb", array("t_header", row=>"cell"));

$num_rows   = 5;
$num_cells  = 4;

$T->SetVar(array(title=>"Example 2",
                num_cells=>$num_cells,
                header_text=>"Example of nested blocks")
                );

$T->ParseBlock("t_header");


for ($i=1; $i<=$num_rows; $i++)
{
    if ($i % 2)
    {
    $row_color = "#c9edfb";
    }
    else
    {
    $row_color = "#cec7fb";
    }

    $T->SetVar("row_color", $row_color);

    for ($j=1; $j<=$num_cells; $j++)
    {
        $T->SetVar("text", "Row $i Cell $j");
        $T->ParseBlock("cell");
    }

    $T->ParseBlock("row");
    $T->CleanVar("cell");
}

$T->Parse("row", "t_header", true);

$T->CleanBlock(array("row", "t_header"));

$T->Parse("CONTENT", "tb");
$T->Parse("OUT", "main");

$T->Append2Var("OUT", date("m/d/Y H:i:s", time()));

$T->PrintOut();

?>
For more information send a message to info at phpclasses dot org.