| |
Basic Example
Here I'll show you an simple example holding many basic features
First we write the PHP script
<?php
function foo()
{
return("text from foo");
}
function foop($text)
{
return("my parameter:".$text);
}
require_once('sptpl.php');
require_once('sptpl.inc');
require_once('sptpl_db.php');
$t=new sptpl();
$t->LoadTemplate('test1.xml');
$t->SetVar("name","George");
$t->SetVar("MyName","Sam");
$bar['foo']='Index foo';
$t->SetVar("bar",$bar);
$t->run("test1.txt");
?> |
Second step, write the configuration file test1.xml
| <?xml version='1.0' ?>
<template>
<template>
<constant name='const1' value = '1'/>
<constant name='const2' value = '2'/>
<report>
<beginreport>
Hi
My second test
</beginreport>
<OpenPage>
Page header.
</OpenPage>
<row id='pippo'>
Hello {$name}, my name is {$MyName}
</row>
<row id='second'>
I'm the index 'bar' of foo {$bar['foo']}
</row>
<row>
Output from the function foo: {foo()}
</row>
<row>
Function with one parameter: {foop('hello world')}
</row>
<row VPos='Relative' RowPos='+2'>
2 row after 'Function with one parameter'
</row>
<row VPos='Relative' RowPos='-2'>
Before the last one
</row>
<row VPos='absolute' RowPos='20'>
At line 20
</row>
<row VPos='NewPage'>
New page, First Line!!!
</row>
<newpage/>
<row>Another page</row>
<row vpos='absolute' rowpos='5'/>
<closepage>
Page end
</closepage>
<closereport>
End!That's all folk!
</closereport>
</report>
</template>
|
|
|