TPLN is a PHP class. It requires this declaration.
<?php
include("TPLN/TPLN.php");
//
Inclusion of file
$TPLN
= new TPLN; //
Object declarationde l'object
// ... suit of program
?>
|
Open() |
The Open() function serves to open the file
template the file can have any extension (. htm. html. tpl,...).
Open( string
filename [, CACHED,
int time
] )
Example : |
Simple opening :
$TPLN->Open("my_file");
Opening with cache to 3600 seconds is 1 hour :
if
( !$TPLN
->Open("my_file",CACHED,
3600) ){
//code to execute to generate the file
}
$TPLN->Write();
// print result
|
Since TPLN version 1.3, for multiple file opening it's preferable to use
DefineTemplate() |
|
DefineTemplate() |
DefineTemplate() function serves
to open multiple template using a name.
DefineTemplate( array
filename
)
Exemple : |
$TPLN->DefineTemplate(array("TOP"=>"top.html",
"BOTTOM" => "bottom.html");
|
See also SetTemplate() |
|
SetTemplate() |
SetTemplate() function serves to select
a template opened before with Open() ou DefineTemplate().
Its parameter can be a number or a string.
SetTemplate( string|int
file )
Exemple : |
SetTemplate with Definetemplate
:
$TPLN->DefineTemplate(array("TOP"=>"top.html",
"BOTTOM" => "bottom.html");
$TPLN->SetTemplate("TOP");//choose
template TOP
... //code to execute
SetTemplate with Open :
$TPLN->Open("top.html");//number
0
$TPLN->Open("bottom.html");
//number
1
$TPLN->SetTemplate(0);//we
choose template TOP
...
//code
to execute
|
|
|
Parse() |
The Parse() function serves to replace a
variable defined in your file template.
TPLN uses a pseudo language object of style javascript to reach your variable
thanks to the separator ". ".
This function also possesses a parameter optional functions.
The one serves to format the text here of replace.
These options are the following :
- |B adds <b></b> to replace what makes it
bold
- |I adds <i></i> to replace what makes it
italic
- |U adds<u></u> to replace what makes it
underline
- |Php function name any Php functions (ucfirst
for example)
Parse( string
item , string
replace [, string
functions ] )
Example : |
Parse :
$TPLN->Parse("my_variable","replace");
Parse in bloc:
$TPLN->Parse("my_bloc.my_variable","replace");
Parse in bloc with format:
$TPLN->Parse("my_bloc.my_variable","replace","|B");
|
|
|
FastParse() |
FastParse() function is the same function
as Parse() except it evits you to rewrite a variable
php
FastParse( string
item [, string
functions ] )
Exemple : |
FastParse :
$name=
"my_name";
$TPLN->FastParse("name");
the same as :
$TPLN->Parse("name",$name);
|
Pour remplacer automatiquement les variables provenant des session, de Post
ou Get voir les fonctions ParseSessionVar(),
ParseGetVar(), ParsePostVar(). |
|
ParseGlobals() |
The ParseGlobals() function serves
to replace all variable Php having the same name that the variables of
your file template.
ParseGlobals(
)
Exemple : |
$nom
= "my_name";
$TPLN->Open("file.html");
/* parse automatically variable {$nom} of
you template by Php variable $nom */
|
this function can be called automatically at the opening of a file template
cf TPLN_Cfg.php. |
|
Loop() |
The Loop() function is applied to a block
to signal its repetition.
You can also write this manner
Loop(this) orLoop() to make a Loop of the last definite Bloc
Attention :it is counseled to use
the complete path of the block if it is an overlapped bloc !
Loop( [
string blocname ]
)
Example : |
Loop :
for($i=0,$i
< 10;$i++){
$TPLN->Parse("my_bloc.my_variable","$i");
$TPLN->Loop("my_bloc");
ou bien
$TPLN->Loop();
ou
encore
$TPLN->Loop(this);
}
|
|
|
EraseItem() |
the EraseItem() function serves to
erase a variable.
EraseItem( string
item )
Example : |
EraseItem :
$TPLN->EraseItem("my_variable");
EraseItem in a bloc:
$TPLN->EraseItem("my_bloc.my_variable");
|
|
|
EraseBloc() |
The EraseBloc() function serves to
erase a bloc.
EraseBloc( string
blocname )
Example : |
EraseBloc :
$TPLN->EraseBloc("my_bloc");
|
|
|
ParseBloc() |
The ParseBloc() function serves to
replace a whole block with its included beacons.
ParseBloc( string
blocname , string
replace )
Example : |
ParseBloc :
$TPLN->ParseBloc("my_bloc"
, "no more bloc !");
|
|
|
LoadArrayInBloc() |
LoadArrayInBloc() serves to parse
an entire bloc by the associated key of an array.
LoadArrayInBloc( array
array)
Exemple : |
LoadArrayInBloc :
$array[]
= array("User"=>"Me",
"Password"=>"test");
$TPLN->LoadArrayInBloc("my_bloc"
, $arr);
|
|
|
IncludeFile() |
IncludeFile() serves to parse a variable
by your file content.
IncludeFile( string
variable ,
string
filename)
Exemple : |
$TPLN->IncludeFile("my_variable","file.html");
|
Since version 1.3, TPLN supports Php file. |
|
GetBlocInFile() |
The GetBlocInFile() function serves
to return a whole block of the template file.
GetBlocInFile( string
blocname )
Example : |
GetBlocInFile :
$bloc
= $TPLN->GetBlocInFile("my_bloc");
|
|
|
GetFile() |
The GetFile() function serves to return
the file content.
If optionnal parameter blocname is precised the function will
return blocname in the file.
GetFile( string
filename ,
[ string
blocname ]
)
Example : |
Getfile (open file file.html
et return bloc1 of file.html) :
$file=
$TPLN->GetFile("file.html","bloc1");
|
|
|
Write() |
The Write() function serves to print the
file template.
Write( )
Example : |
Write :
$TPLN->Write();
|
|
|
Output() |
The Output() function serves to return
the content of the template file.
OutPut( )
Example : |
Output :
$file_parsed
= $TPLN->Output();
|
|
|
ItemExists() |
ItemExists() function serves to know
if a variable exists in the template.
ItemExists(string
variable, [string
bloc])
Return true if found else return false. |
|
BlocExists() |
BlocExists() function serves to know
if a bloc exists in the template.
BlocExists(string
bloc)
Return true if found else return false. |
|
|