forked from unusorin/php-xtemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex1.php
executable file
·50 lines (39 loc) · 1.21 KB
/
ex1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* example 1
* demonstrates basic template functions
* -simple replaces ( {VARIABLE1}, and {DATA.ID} {DATA.NAME} {DATA.AGE} )
* -dynamic blocks
*
* @package XTemplate_Examples
* @author Barnabas Debreceni [[email protected]]
* @copyright Barnabas Debreceni 2000-2001
* @author Jeremy Coates [[email protected]]
* @copyright Jeremy Coates 2002-2007
* @see license.txt LGPL / BSD license
* @link $HeadURL: https://xtpl.svn.sourceforge.net/svnroot/xtpl/trunk/ex1.php $
* @version $Id: ex1.php 16 2007-01-11 03:02:49Z cocomp $
*/
include_once('./xtemplate.class.php');
$xtpl = new XTemplate('ex1.xtpl');
// simple replace
$xtpl->assign('VARIABLE', 'TEST');
// parse block1
$xtpl->parse('main.block1');
// uncomment line below to parse block2
//$xtpl->parse('main.block2');
/**
* you can reference to array keys in the template file the following way:
* {DATA.ID} or {DATA.NAME}
* say we have an array from a mysql query with the following fields: ID, NAME, AGE
*/
$row = array('ID'=>'38',
'NAME'=>'cocomp',
'AGE'=>'33'
);
$xtpl->assign('DATA',$row);
// parse block3
$xtpl->parse('main.block3');
$xtpl->parse('main');
$xtpl->out('main');
?>