Location: PHPKode > projects > Rain TPL > raintpl_1.9/documentation/en.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="description" content="Rain TPL, the easy template engine php, that compile template. Open source under GNU GPL license.">
		<meta name="keywords" content="template engine,easy template engine,raintpl,rain tpl,template,template php,template engine php,open source php,documentation">
		<title>Rain TPL, the easy template engine php, that compile template. Open source under GNU GPL license.</title>
		<link rel="stylesheet" type="text/css" href="layout.css" media="all">
	</head>

	<body>
		<a name="index"></a>
		<div id="logo"><a href="http://www.raintpl.com"><img src="images/logo.gif" alt="" width="351" height="77" border="0"></a></div>
		<div class="docu">
			<h1>RainTPL Documentation [EN]</h1>
			<blockquote>
				The documentation is divided in <i>documentation for designers</i> and <i>documentation for programmers</i>.</blockquote>
			<h2><i>Documentation for designers</i></h2>
			<ul class="documentation">
				<li><a href="#knowledgebase">Knowledge Base</a>
				<li><a href="#tagsoverview">RainTPL tags</a>
				<li style="list-style: none;">
					<ul>
						<li><a href="#noparse">{noparse}{/noparse}</a>
						<li><a href="#ignore">{ignore}{/ignore}</a>
						<li><a href="#variable">{$variable_name}</a>
						<li><a href="#constant">{#constant_name#}</a>
						<li><a href="#ifcondition">{if condition="<em>condition</em>"}{elseif condition="<em>condition</em>"}{else}{/if}</a>
						<li><a href="#loops">{loop name="<em>loop name</em>"}{/loop}</a>
						<li><a href="#include">{include="<em>file</em>"}</a>
					</ul>            
			</ul>
			<p class="h2">Documentation for PHP programmers</p>
			<ul class="documentation">			
				<li><a href="#installation">Installation</a>
				<li><a href="#requisite">Requisite</a>
				<li><a href="#methods">RainTPL Methods</a><br>
				<li style="list-style: none; display: inline">
					<ul>
						<li><a href="#constructor">RainTPL()</a> (constructor function)<li><a href="#assign">assign()</a>
						<li><a href="#draw">draw()</a><br>
					</ul>
				<li><a href="#configuration">Configuration</a>
			</ul>
		</div>
		<a name="knowledgebase"></a>
		<div class="docu">
			
			<p class="h2">Documentation for designers</p>
			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>
			<p><span class="text_title">Knowledge Base</span></p>
			<p>RainTPL is a <i>PHP template engine</i> that uses  HTML templates. </p>
			<p>RainTPL is compatible with PHP4 and PHP5.</p>
			<p>Templates are HTML files plus a few additional commands that allow you to dynamically load the contents, leaving  the graphics of the template unchanged. The Rain TPL precompile templates when they are modified to speed up the loading performance. It 'was designed to work with themes, which suggest a structure as follows:</p>
			<p>
			<b>For the work with different themes I advice to structure files and directory as follows:</b><br>
			</p>
			<ul>
				<li class="dir_icon">themes
				<li style="list-style: none; display: inline">
					<ul>
						<li class="dir_icon">acid ( theme )
						<li style="list-style: none; display: inline">
							<ul>
								<li class="dir_icon">compiled ( compiled template. Automatically created by the RainTPL. )
								<li class="html_icon">home .html ( template )
								<li class="html_icon">news.html ( template )
								<li class="html_icon">contact.html ( template )
								<li class="css_icon">style.css ( style sheet )
								<li style="list-style: none; display: inline">
									<ul>
										<li class="dir_icon">images ( images dir )
										<li style="list-style: none; display: inline">
											<ul>
												<li class="img_icon">raintpl.gif ( image )
											</ul>
									</ul>
							</ul>
						<li class="dir_icon">blue ( other theme )
						<li style="list-style: none; display: inline">
							<ul>
								<li class="dir_icon">compiled
								<li class="html_icon">home .html
								<li class="html_icon">news.html
								<li class="html_icon">contact.html
								<li class="css_icon">style.css
								<li style="list-style: none; display: inline">
									<ul>
										<li class="dir_icon">images
										<li style="list-style: none; display: inline">
											<ul>
												<li class="img_icon">raintpl.gif
											</ul>
										
									</ul>
								
							</ul>
						
					</ul>
				
					
			</ul>
			<p>I advice to create templates using <b>relative paths</b>, because RainTPL in compilation will change all relative paths to the <b>correct server paths</b>. Absolute paths and paths ending with <tt>#</tt> will be not changed in compilation.<br>
				<br>
				<b>Example:</b><br>
			</p>
			<div class="layout">
				<p><span class="comment">&lt;!--img, link, and background--&gt;</span><br>
					&lt;link href="style.css" type="text/css" rel="stylesheet"&gt;<br>
					&lt;img src="images/raintpl.gif"&gt;<br>
					&lt;td background="images/bg.gif"&gt;<br>&lt;a href=&quot;#&quot; style=&quot;background-image: url(images/backtotop.gif);&quot;&gt;<br>
					<br>
					<span class="comment">&lt;!-- paths with # in the end not change--&gt;</span><br>
					&lt;link href="http://style.css" type="text/css" rel="stylesheet"&gt;<br>
					&lt;img src="images/raintpl.gif#"&gt;<br>
				</p>
			</div>
			<br>
			<b>Output html:</b><br>
			<div class="layout2">
				&lt;link href="themes/acid/style.css" type="text/css" rel="stylesheet"&gt;<br>
				&lt;img src=&quot;themes/acid/images/raintpl.gif&quot;&gt;<br>
				
				&lt;td background="themes/acid/images/bg.gif"&gt;<br>
				&lt;a href=&quot;#&quot; style=&quot;background-image: url(themes/acid/images/backtotop.gif);&gt;<br>
				<br>
				
				&lt;link href="http://style.css" type="text/css" rel="stylesheet"&gt;<br>
				&lt;img src="images/raintpl.gif"&gt;<br>
			</div>
		</div>



    
	<a name="tagsoverview"></a>    
    <div class="docu">
        
        <p class="h2">Documentation for designers</p>

       <div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>
<span class="text_title">Rain TPL tags</span><br>
        List of Rain TPL tags:<br>
        <br>
					<ul class="documentation">
						<li><a href="#noparse">{noparse}{/noparse}</a>
						<li><a href="#ignore">{ignore}{/ignore}</a>
						<li><a href="#variable">{$variable_name}</a>
						<li><a href="#constant">{#constant_name#}</a>
						<li><a href="#ifcondition">{if condition="<em>condition</em>"}{elseif condition="<em>condition</em>"}{else}{/if}</a>
						<li><a href="#loops">{loop name="<em>loop name</em>"}{/loop}</a>
						<li><a href="#include">{include="<em>file</em>"}</a>
					</ul>  
    </div>


    <a name="noparse"></a>
    <div class="docu">
        
        <p class="h2">Documentation for designers</p>
			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>
			<p><span class="text_title"><tt>{noparse}{/noparse}</tt></span></p>
			<p>All between <tt>{noparse}</tt> and <tt>{/noparse}</tt>will not be compiled.</p>
			<b>Example:</b><br>
			
			<div class="layout">
            <span class="comment">&lt;!-- this will be compiled--&gt;</span><br>
            <span class="variable">{$variable}</span><br>
            &lt;img src="images/rtpl.gif"&gt;<br>
            <span class="tag">{loop name=</span><span class="string">"news"</span><span class=
            "tag">}</span><span class="variable">{$value.title}</span><span class="tag">{/loop}</span><br>
            <br>
            <span class="tag">{noparse}</span><br>
				<span class="comment">&lt;!-- this  will not be compiled--&gt;</span><br>
				<span class="variable">{$variable}</span><br>
            &lt;img src="images/rtpl.gif"&gt;<br>
            <span class="tag">{loop name=</span><span class="string">"news"</span><span class=
            "tag">}</span><span class="variable">{$value.title}</span><span class="tag">{/loop}</span><br>
            <br>
            <span class="tag">{/noparse}</span><br>
            <br>
        </div>
        <p>In the <i>compiled template</i> (<tt>compiled/your-template_12345678.php</tt>) you will find everything between <tt>{noparse}{/noparse}</tt> in the same way as in your <i>html template</i> (<tt>your-template.html</tt>) </p>
			<b>Compiled template:</b><br>
			<div class="layout layout3">            
				<span class="comment">&lt;!-- this  will not be compiled--&gt;</span><br>
				<span class="variable">{$variable}</span><br>
            &lt;img src="images/rtpl.gif"&gt;<br>
            <span class="tag">{loop name=</span><span class="string">"news"</span><span class=
            "tag">}</span><span class="variable">{$value.title}</span><span class="tag">{/loop}</span><br>           
            <br>
        </div>
		</div>


    <a name="ignore"></a>
    <div class="docu">
        
        <p class="h2">Documentation for designers</p>
			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>
			<p><span class="text_title"><tt>{ignore}{/ignore}</tt></span></p>
			<p> All between tags <tt>{ignore}</tt> and <tt>{/ignore}</tt> is deleted in the compiled file.<br>
				<br>
				<b>Example:</b><br>
			</p>
			<div class="layout">
            <span class="comment">&lt;!-- text --&gt;</span><br>
            Lorem ipsum<br>
            <br>
            <span class="comment">&lt;!-- will be ignored in the compiled file--&gt;</span><br>
            <span class="tag">{ignore}</span><br>
            dolor sit amet<br>
            <span class="tag">{/ignore}</span>
        </div>
        <p>In the <i>compiled template</i> (<tt>compiled/your-template_12345678.php</tt>) everything between <tt>{ignore}{/ignore}</tt> won't be compiled at all. </p>
			<b>Compiled template:</b><br>
			<div class="layout layout3">
            <span class="comment">&lt;!-- text --&gt;</span><br>
            Lorem ipsum<br>
            <br>
            <span class="comment">&lt;!-- will be ignored in the compiled file--&gt;</span><br>            
        </div>
		</div>


    <a name="variable"></a>
    <div class="docu">
        
        <p class="h2">Documentation for designers</p>
			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>
			<p><span class="text_title"><tt>{$<em>variabile_name</em>}</tt></span></p>
			<p>Variables are the dynamic contents of the template, valorized in the execution of the script with RainTPLs <a href=
        "#assign"><tt>assign()</tt></a> methode.<br>Variable names are <b>case sensitive</b>.</p>

        <br>
				
				<b>Example:</b><br>
			<div class="layout">
				My favourite color is &lt;span style=&quot;color:<span class="variable">{$color}</span>;&quot;&gt;<span class=
            "variable">{$color}</span>&lt;/span&gt;</div>
			<br>
			<b>Output:</b>
			<div class="layout2">
            My favourite color is <font color="blue">blue</font>
        </div>
			<br>
			<p>You can use arithmetic operators for simple operations: <tt>+, -, *, /, %</tt><br></p>
			<br>
				<b>Example:</b>

        <div class="layout">
            <span class="comment">&lt;!-- num &egrave; = a 2 --&gt;</span> <span class="variable"><br>
            {$num+10}</span>
        </div>
			<br>
			<b>Output:</b>
			<div class="layout2">
            12<br>
        </div>
			<br>

        <p>RainTPL can use the functions on the variables. The first parameter will function as the variable. The syntax is:<br>
				<tt>{$var|<em>function_name</em>:<em>par_1</em>,<em>par_2</em>}<br>
				</tt></p>

        <b>Example:</b>

        <div class="layout">
            <span class="comment">&lt;!-- news= Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In metus
            mauris, condimentum vulputate, condimentum ac, gravida nec, sapien. --&gt;</span><br>
            <span class="comment">&lt;!-- la function substr is inner to php --&gt;<br></span> <span class=
            "variable">{$news</span>|substr:0,10<span class="variable">}</span><br>
        </div>
			<br>
			<b>Output:</b>
			<div class="layout2">
            Lorem ipsum...<br>
        </div>
			<br>
			<p>The variables passed to a template can be either one-dimensional (strings, numbers, boolean values) and multidimensional (arrays, objects). </p>
			<p>For access to an array of values you can use either the dot &quot;<tt>.</tt>&quot; that the square brackets &quot;<tt>[]</tt>&quot; to access an object instead of using the arrow &quot;<tt>-&gt;</tt>&quot;. RainTPL can also access the values in an array of an object using the tag <a href="#loops"><tt>{loop}</tt></a>.<br>
				<br>
				<b>Example</b>:<br>
				<tt>Array :<br>
				</tt></p>
			<ul>
				<li class="var_icon">user =&gt;</li>
				<li style="list-style: none; display: inline">
					<ul>
						<li class="var_icon">login =&gt; Rain</li>
						<li class="var_icon">site =&gt; www.rainelemental.net</li>
						<li class="var_icon">lang =&gt;
							<ul>
								<li>0 =&gt; italiano</li>
								<li>1 =&gt; english</li>
							</ul>
							<br>
						</li>
					</ul>
				</li>
			</ul>
			<br>
			<b>Template:</b><br>
			<div class="layout">
            <span class="comment">&lt;!-- you can use . or [ ], for object use -&gt;, example {$user-&gt;login} e
            {$user-&gt;site} --&gt;</span><br>
            My nickname is <span class="variable">{$user.login}, {$user[site]}</span>
            speak<span class="variable">{$user.lang[0]}</span> and <span class="variable">{$user.lang.1}</span>
        </div>
			<br>
			<b>Output:</b><br>
			<div class="layout2">
            My nickname is Federico, www.rainelemental.net speak italiano and english
        </div>
			<br>
			<br>
			<b>Note:</b> <tt>{$counter}</tt>, <tt>{$key}</tt> and <tt>{$value}</tt> are reserved variables, taking special value inside a loop. Therefore it is not advisable to call a variable with these names<br>
			<br>
			Other reserved variables are <i>global variables</i> as: <tt>{$GLOBALS}, {$_GET}, {$_POST}, {$_COOKIES}, {$_SESSION}</tt> and <tt>{$_SERVER}</tt>.
    <br>
		</div>


    <a name="constant"></a>
    <div class="docu">
        
        <p class="h2">Documentation for designers</p>

        			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>

        <span class="text_title"><tt>{#<em>constant_name</em>#}</tt></span><br>
			<br>
			You can access constants defined in the PHP code using the tag <tt>{#<em>constant_name</em>#}</tt>.<br>
        <br>
        <b>Example:</b><br>
         <div class="layout layout3">
        	define( 'THEME', 'default' );
		</div>
		<br>
		<b><b>Template:</b></b><br>
        <div class="layout">
            {#THEME#}
        </div><br>
        <br>
        <b>Output:</b><br>
			<div class="layout2">
            default
        </div>
			<br>
			<p>There is no need to define new constants if the constants are already defined (i.e. if your script includes another PHP files with defined constants).
			<br>All of them will be compiled accordingly by using <tt>{#constant_name#}</tt>in the <i>HTML template</i>.</p>
		</div>


    <a name="ifcondition"></a>
    <div class="docu">
        
        <p class="h2">Documentation for designers</p>

        			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>

        <span class="text_title style1"><tt>{if condition="<em>condition</em>"}{elseif
        condition="<em>condition</em>"}{else}{/if}</tt></span><span class="style1"><br>
				<br>
			</span>This tag is the equivalent of php if statement.<span class="style1"> You can use it with the following syntax:<br>
				<br>
			</span>
			<ul class="style1">
            <li><tt>{if condition="<em>condition</em>"}{\if}</tt>, if condition is true draw html between<tt>{if}</tt> and <tt>{/if}</tt>.</li>

            <li><tt>{if condition="<em>condition</em>"}{else}{\if}</tt>, if condition is true draw html between <tt>{if}</tt> and <tt>{else}</tt>,
            if is false between <tt>{else}</tt> and <tt>{\if}</tt></li>

            <li><tt>{if condition="<em>condition</em>"}{elseif condition="<em>condition</em>"}{else}{\if}</tt>, if condition is
            true draw html between <tt>{if}</tt> and <tt>{elseif}</tt>, if is false check the condition of elseif, if that is false draw
            the html between else and if.</li>
        </ul>
			<br>
        <b>Example:</b><br>
			<div class="layout style1">
            <span class="comment">&lt;!-- year = 26 --&gt;</span><br>
            <span class="tag">{if condition=</span><span class="string">"</span><span class="variable">$year</span>
            <span class="string">&gt; 18"</span><span class="tag">}</span>major<span class="tag">{/if}</span><br>
            <span class="tag">{if condition=</span><span class="string">"</span><span class="variable">$year</span>
            <span class="string">&gt; 18"</span><span class="tag">}</span>major<span class="tag">{else}</span>not
            major<span class="tag">{/if}</span><br>
            <span class="tag">{if condition=</span><span class="string">"</span><span class="variable">$year</span>
            <span class="string">&lt; 20"</span><span class="tag">}</span>less than 20 years<span class="tag">{elseif
            condition=</span><span class="string">"</span><span class="variable">$year</span> <span class="string">&lt;
            30"</span><span class="tag">}</span>less than 30 years<span class="tag">{/if}</span>
        </div>
			<br>
        <br>
        <b>Output:</b><br>
			<div class="layout2 style1">
            major<br>
            major<br>
            less than 30 years
        </div>
			<span class="style1"><br>
        In "<em>condition</em>" use variables without comma "{", "}", and use regular PHP code.</span>
    </div>


    <a name="loops"></a>
    <div class="docu">
        
        <p class="h2">Documentation for designers</p>

        			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>

        <span class="text_title"><tt>{loop name="<em>loop name</em>"}{/loop}</tt></span><br>
			<br>
			This command allows you to read the elements of an array and an object within a loop. Among the loop tag () and (/ loop) You can use some special variables:<br>
			<br>
			<ul>
				<li><tt>{$key}</tt>, returns the key element of the selected array 
				<li><tt>{$value}</tt>, returns the key element of the array selected. If we access a value that lies within an array we use the scoping.
				<li><tt>{$counter}</tt>, returns the value of the counter, which starts at 0. To run it from any other number is enough to perform a sum, eg:<tt>{$counter+1}</tt>
			</ul>
			<b>Example:</b><br>
				<br>
				<tt>Array:<br>
					<br>
				</tt>
			<ul>
				<li class="var_icon">user =&gt;</li>
				<li style="list-style: none; display: inline">
					<ul>
						<li class="var_icon">login =&gt; Rain</li>
						<li class="var_icon">site =&gt; www.rainelemental.net</li>
						<li class="var_icon">state =&gt; Italia</li>
						<li class="var_icon">region =&gt; Sicilia</li>
					</ul>
				</li>
			</ul>
			<br>
        <b>Template:</b><br>
			<div class="layout">
            <span class="comment">&lt;!-- loop the variable user --&gt;</span><br>
            <span class="tag">{loop name=</span><span class="string">"user"</span><span class="tag">}</span><br>
            <span class="variable">{$counter+1}</span> ) <span class="variable">{$key}</span> = <span class=
            "variable">{$value}</span>&lt;br&gt;<br>
            <span class="tag">{/loop}</span>
        </div>
			<br>
        <br>
        <b>Output:</b><br>
			<div class="layout2">
            1 ) login = Rain<br>
            2 ) site = www.rainelemental.net<br>
            3 ) state = Italia<br>
            4 ) region = Sicilia
        </div>
			<br>
        <br>
        <br>
        <b>Example 2:</b><br>
			<br>
			<tt>Array:<br>
				<br>
			
			<ul>
				<li class="var_icon">user_list =&gt;</li>
				<li style="list-style: none; display: inline">
					<ul>
						<li class="var_icon">0 =&gt;</li>
						<li style="list-style: none; display: inline">
							<ul>
								<li class="var_icon">name =&gt; Pippo</li>
								<li class="var_icon">color =&gt; red</li>
							</ul>
						</li>
					</ul>
					<ul>
						<li class="var_icon">1 =&gt;</li>
						<li style="list-style: none; display: inline">
							<ul>
								<li class="var_icon">name =&gt; Topolino</li>
								<li class="var_icon">color =&gt; yellow</li>
							</ul>
						</li>
					</ul>
					<ul>
						<li class="var_icon">2 =&gt;</li>
						<li style="list-style: none; display: inline">
							<ul>
								<li class="var_icon">name =&gt; Paperino</li>
								<li class="var_icon">color =&gt; blue</li>
							</ul>
						</li>
					</ul>
				</li>
			</ul></tt>
			<br>
        <b>Template:</b><br>
			<div class="layout">
            <span class="comment">&lt;!-- loop the variable user --&gt;</span><br>
            <span class="tag">{loop name=</span><span class="string">"user_list"</span><span class="tag">}</span><br>
            <span class="variable">{$key}</span> - <span class="variable">{$value.name}</span>, <span class=
            "variable">{$value.color}</span> &lt;br&gt;<br>
            <span class="tag">{/loop}</span>
        </div>
			<br>
        <br>
        <b>Output:</b><br>
			<div class="layout2">
            0 - Pippo, red<br>
            1 - Topolino, yellow<br>
            2 - Paperino, blue
        </div>
			<br>
        <b>Recursive loops</b> are allowed.
    </div>


    <a name="include"></a>
    <div class="docu">
        
        <p class="h2">Documentation for designers</p>

        			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>

        <span class="text_title"><tt>{include="<em>file</em>"}</tt></span><br>
        <br>
			This tag allows to include another HTML template.<br>
			You can use a PHP variable to load files dinamically, for example to load the central part of a site.<br>
			<br>
        <b>Example:</b><br>
			<div class="layout">
            <span class="comment">&lt;!-- include menu.html --&gt;</span> <span class="tag"><br>
            {include=</span><span class="string">"menu"</span><span class="tag">}</span><br>
            <span class="comment">&lt;!-- include $pagina --&gt;</span> <span class="tag"><br>
            {include=</span><span class="string">"</span><span class="variable">$pagina</span><span class=
            "string">"</span><span class="tag">}</span><br>
        </div>
	</div>


		
		
    <a name="installation"></a>
    <div class="docu">
        
        <p class="h2">Documentation for programmers</p>

        			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>

        <span class="text_title">Installation<br></span>
        <br>
        <ul>
        <li><a href="http://www.raintpl.com/?page_id=download">Download</a> and extract RainTPL.</li>
       <li> copy the files <em><tt>rain.tpl.class.php</tt></em> and <em><tt>rain.tpl.compile.class.php</tt></em> in your projects include directory (ex. <em>includes</em>).</li>
       <li> You must create a templates directory (ex. <em>themes</em>),
					<div class="layout layout3">
            <span style="color: rgb(128, 128, 128);">//include Rain TPL</span><br>
            <span style="color: rgb(177, 177, 0);">include</span><span style="color: rgb(102, 204, 102);">(</span>
            <span style="color: rgb(255, 0, 0);">'inc/rain.tpl.class.php'</span> <span style=
            "color: rgb(102, 204, 102);">)</span>;
        </div>
				</li>
				<li>include in your php script the <tt>raintpl.class.php</tt> file in this way:<br>
					<br>
				
			</ul>
        <a name="requisite"></a>
        <span class="text_title">Requisite</span><br>
        <br>
        Rain TPL is compatibile with <b>PHP 4 </b>and <b>PHP 5</b>.
    </div>



    <a name="methods"></a>
    <div class="docu">
        
        <p class="h2">Documentation for programmers</p>

        			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>

        <span class="text_title">Methods</span><br>
        <br>
        RainTPL implements:<br>
			<div style="margin-left: 2em">
            <br>

            <ul>
                <li><a href="#constructor">RainTPL</a> (constructor function)</li>

                <li><a href="#assign">Assign</a></li>

                <li><a href="#draw">Draw</a></li>
            </ul>
        </div>
		</div>


    <a name="constructor"></a>
    <div class="docu">
        
        <p class="h2">Documentation for programmers</p>

       			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>

        <span class="text_title"><tt>RainTPL()</tt></span><br>
        <br>
        <tt><em>object</em> <strong>rainTPL</strong>( <em>string</em> template_directory <em>= 'themes/default/'</em> )</tt><br>
        <br>Initialize RainTPL class and set the template directory. Rain TPL remembers the template directory in all the script execution.<br>
        <br>
        <br>
        <b>Example:</b><br>
			<div class="layout layout3">
            &lt;?php<br>
            <br>
            <span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;//include RainTPL</span><br>    include( 'includes/rain.tpl.class.php' );<br>
            <br>
            <span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;//initialize</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;$tpl = new RainTPL( $template_directory = 'themes/acid' );<br>
            <br>
            ?&gt;
        </div>
		</div>



    <a name="assign"></a>
    <div class="docu">
        
        <p class="h2">Documentation for programmers</p>

        			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>

        <span class="text_title"><tt>assign()</tt></span><br>
        <br>
        <tt><em>null</em> <strong>assign</strong>( <em>string</em> variable_name, <em>mixed</em> variable_value )</tt><br>
        <tt><em>null</em> <strong>assign</strong>( <em>mixed</em> variable_name )</tt><br>
        <br>
			You can use it is to assign a value to a variable, which assign an associative array that contains <b>name / value</b> pairs.<br>
			<br>
			<b>Example:</b><br>
			<div class="layout layout3">
            &lt;?php<br>
            <br>
            <span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;//assign</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;$tpl-&gt;assign( 'message', 'Hello World!' );<br>
				<br>
				
            ?&gt;
        </div>
			<br>
			<br>
			<b>Use template variable:</b><br>
			<div class="layout">
            <span class="variable">{$message}</span><br>
			</div>
			<br>
			<p>You can also assign an array:<br>
				<tt>array( 'name'=&gt;'value',
        'name'=&gt;'value' ) </tt><br>
			</p>
			<p><b>Example:</b><br>
			</p>
			<div class="layout layout3">
            &lt;?php<br>
				<br>$user = array( <br>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;login&quot;=&gt;&quot;Rain&quot;, <br>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;site&quot; =&gt; &quot;www.rainelemental.net&quot;, <br>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;state&quot; =&gt; &quot;Italia&quot; <br>
				&nbsp;&nbsp;&nbsp;&nbsp;);<br>
            <span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;//assign array</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;$tpl-&gt;assign( $user );<br>
            <br>
            ?&gt;
        </div>
			<br>
			<br>
			<b>Use template variable:</b><br>
			<div class="layout">
				<span class="variable">{$user.login}</span>, <span class="variable">{$user.site}</span>, <span class=
            "variable">{$user.state}</span><br>
					<br>
				<span class="comment">&lt;!-- You will get the same result by using --&gt;</span><br>
				<span class="variable">{$user[login]}</span>, <span class="variable">{$user[site]}</span>, <span class="variable">{$user[state]}<br>
				</span></div>
		</div>


    <a name="draw"></a>
    <div class="docu">
        
        <p class="h2">Documentation for designers</p>

       			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>

        <span class="text_title"><tt>draw()</tt></span><br>
        <br>
        <tt><em>string</em> <strong>draw</strong>( <em>string</em> template_name, <em>bool</em> return_string = false )</tt><br>
        <br>
        Draw the template <tt>$template_name</tt>.<br>
        If <tt>return_string = true</tt>, return a string with designed template.<br>
        <br>
			<b><b>Example:</b></b><br>
			<div class="layout layout3">
            &lt;?php<br>
            <span class="comment"><br>
            &nbsp;&nbsp;&nbsp;&nbsp;//include RainTPL</span><br>    include( 'inc/rain.tpl.class.php' );<br>
            <br>
            <span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;//initialize</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;$tpl = new RainTPL( $template_directory = 'themes' );<br>
            <br>
            <span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;//assign</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;$tpl-&gt;assign( 'message', 'Hello World!' );<br>
            <br>
            <span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;//draw template...<br></span>
            &nbsp;&nbsp;&nbsp;&nbsp;$tpl-&gt;draw( 'test' );<br>
            <br>
            <span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;//...or get template as string<br>
            &nbsp;&nbsp;&nbsp;&nbsp;// $stringa = $tpl-&gt;draw( 'test', true );</span><br>
            <br>
            ?&gt;
        </div>
		</div>


    <a name="configuration"></a>
    <div class="docu">
        
        <p class="h2">Documentation for designers</p>

        			<div class="prevnext" align="right"><b><a href="#index">^ Index ^</a></b>&nbsp;</div>

        <span class="text_title">Configuration</span><br>
        <br>
			Some features of RainTPL are defined as constants in the file <tt>rain.tpl.class.php</tt>. <br>
			The following are the configurable features: <br>
			<br>

        <ul>
            <li><tt>TPL_EXT = "<em>html</em>"</tt>, template extension.<br>
					you may change the predefined *.html extension to whatever you likle (ex. <tt>tpl, htt, htpl</tt> )</li>
				<li><tt>RAINTPL_PHP_ENABLED = <em>false<br>
						</em></tt>set <tt>true</tt> for using php tag inside template ("<tt><em>&lt;?php</em>",
            "<em>?&gt;</em></tt>").</li>
            <li><tt>TPL_CACHE_ENABLED = <em>true</em></tt><br> true to enable the cache and precompile only when there are some template updates</li>
			</ul>
        <div class="prevnext" align="right"><b><a href="#index">^ Back to top ^</a></b>&nbsp;</div>
    </div>
    
    <br>
    <div align="right" style="background: #fff; padding:10px; border-top: 1px solid #ccc;">Copyright <a href="http://www.raintpl.com">RainTPL.com</a></div>

	</body>
</html>
Return current item: Rain TPL