Template Lite - the faster compiling PHP template engine

Custom Functions


capture

Description

This block function will collect the output it encases and store it in a variable instead of displaying it. The variable can then be modified and manipulated.

Arguments

Example

	EXAMPLE
	=============================
	{ capture assign=variable }
	  Now is the time to test things out.
	{/capture}
	{ $variable|upper }

	{capture name=testcapture}
	  Now is the time to test things out.
	{/capture}
	


strip

Description

This function will remove all repeated spaces, new lines, and tabs with a single instance.

Example

	TEMPLATE
	=============================
	{* the following will be all run into one line upon output *}
	{ strip}
		<A HREF="{ $url }">
			<font color="red">This is a test</font>
		</A>
	{ /strip }

	OUTPUT
	=============================
	<A HREF="http://my.domain.com"><font color="red">This is a test</font></A>
	


textformat

Description

This block function is used to clean up spaces, special characters and formats paragraphs by wrapping at a boundary and indenting lines.

Arguments

Example

	EXAMPLE
	=============================
	{ textformat wrap=20 }
		This is a special test of the 20 wrap.
	{ /textformat }


	OUTPUT
	=============================
	This is a special te
	st of the 20 wrap.
	


counter

Description

This function is an incremental counter that will increase by the specified amount each time it is called, or not, depending on how it is called.

Arguments

Example

	TEMPLATE
	=============================
	{* initialize the count *}
	{counter start=0 skip=2 print=false}

	{counter}<br>
	{counter}<br>
	{counter}<br>
	{counter}<br>

	OUTPUT
	=============================
	2<br>
	4<br>
	6<br>
	8<br>
	


cycle

Description

Cycle will alternate between multiple values on each recurring call.

Arguments

Example

	{ foreach value=value from=$data }
	<tr bgcolor="{ cycle values="#eeeeee,#d0d0d0" }">
		<td>{ $value[rows] }</td>
	</tr>
	{ /foreach }

	OUTPUT
	=============================
	<tr bgcolor="#eeeeee">
		<td>1</td>
	</tr>
	<tr bgcolor="#d0d0d0">
		<td>2</td>
	</tr>
	<tr bgcolor="#eeeeee">
		<td>3</td>
	</tr>
	


db_function_call

Description

This function call will allow you to interface with ADOdb Lite and execute any database functions.

Arguments

Example

	TEMPLATE
	=============================
	{ db_function_call db_object=$db_object db_function="Execute" db_query=$query db_assign="result_object"}

	


db_result_call

Description

This function call will allow you to interface with ADOdb Lite and execute any database result set functions.

Arguments

Example

	TEMPLATE
	=============================
	{ db_function_call db_object=$db_object db_function="Execute" db_query=$query db_assign="result_object" db_EOF_assign="eof"}

	{while $eof == 0}
		{ db_result_call db_object=$db_object db_function="fields" db_result_object=$result_object db_assign="result" db_EOF_assign="eof"}
		Name: {$result.name}<br>
		{ db_result_call db_object=$db_object db_function="MoveNext" db_result_object=$result_object db_assign="result" db_EOF_assign="eof"}
	{/while}

	OUTPUT
	=============================
	George
	Mitchel
	Jenny
	


debug

Description

Debug is now a compiler function and operates in the same manner. For more information view the Debug Compiler Function.

 


html_checkboxes

Description

Will insert a checkbox into the template.

Arguments

Example

	TEMPLATE
	=============================
	{ html_checkboxes name="test" }

	OUTPUT
	=============================
	<INPUT TYPE="CHECKBOX" NAME="test">
	


html_hidden

Description

Will insert a checkbox into the template.

Arguments

Example

	TEMPLATE
	=============================
	{ html_hidden name="test" value="stuff" }

	OUTPUT
	=============================
	<INPUT TYPE="HIDDEN" NAME="test" VALUE="stuff"> 
	


html_image

Description

Will insert an image (optionally resized) into the template.

Arguments

Example

	TEMPLATE
	=============================
	{ html_image url="http://www.yoursite.com/image.jpg" }
	{ html_image url="images/me.gif" alt="A picture of me!" }
	{ html_image url="picture.gif" width=500 height=400 }

	OUTPUT
	=============================
	<IMG SRC="http://www.yoursite.com/image.jpg" BORDER="0" ALT="http://www.yoursite.com/image.jpg" WIDTH="174" HEIGHT="350">
	<IMG SRC="images.me.gif" BORDER="0" ALT="A picture of me!" WIDTH="200" HEIGHT="400">
	<IMG SRC="picture.gif" BORDER="0" ALT="picture.gif" WIDTH="500" HEIGHT="400">
	


html_input

Description

Will insert a text box (or optionally a password box) into the template.

Arguments

Example

	TEMPLATE
	=============================
	{ html_input name="test" }

	OUTPUT
	=============================
	<INPUT TYPE="TEXT" VALUE="" NAME="test">
	


html_options

Description

Will create a list of options for a select in the HTML template.

Arguments

Example

	PHP
	=============================
	$tpl->assign('cust_options', array(
			1001 => 'Joe Schmoe',
			1002 => 'Jack Smith',
			1003 => 'Jane Johnson',
		1004 => 'Charlie Brown'));
	$tpl->assign('customer_id', 1001);

	TEMPLATE
	=============================
	<select name=customer_id>
		{ html_options options=$cust_options selected=$customer_id }
	</select>

	OUTPUT
	=============================
	<select name=customer_id>
		<option value="1000">Joe Schmoe</option>
		<option value="1001" selected="selected">Jack Smith</option>
		<option value="1002">Jane Johnson</option>
		<option value="1003">Charlie Brown</option>
	</select>
	


html_radios

Description

Will insert a radio button into the template.

Arguments

Example

	TEMPLATE
	=============================
	{ html_radios name="test" }

	OUTPUT
	=============================
	<INPUT TYPE="RADIO" NAME="test">
	


html_select_date

Description

Will create date dropdowns for you. It can insert any or all of year, month, and day into the template.

Arguments

Example

	TEMPLATE
	=============================
	{ html_select_date }


	OUTPUT
	=============================
	<select name="Date_Month">
	<option value="1">January</option>
	<option value="2">February</option>
	<option value="3>March</option>	
	<option value="4" selected="selected">April</option>
	..... cut .....
	<option value="11">November</option>
	<option value="12">December</option>
	</select>
	<select name="Date_Day">
	<option value="1">01</option>
	<option value="2" selected="selected>02</option>
	..... cut .....
	<option value="31">31</option>
	</select>
	<select name="Date_Year">
	<option value="2006" selected="selected">2006</option>
	</select>	


html_select_time

Description

Will create time dropdowns for you. It can insert any or all of hour, minute, second and meridian into the template.

Arguments

Example

	TEMPLATE
	=============================
	{ html_select_time use_24_hours=true }


	OUTPUT
	=============================
	<select name="Time_Hour">
	<option value="00">00</option>
	<option value="01" selected>01</option>
	..... cut .....
	<option value="22">22</option>
	<option value="23">23</option>
	</select>
	<select name="Time_Minute">
	<option value="00" selected>00</option>
	<option value="01">01</option>
	..... cut .....
	<option value="58">58</option>
	<option value="59">59</option>
	</select>
	<select name="Time_Second">
	<option value="00" selected>00</option>
	<option value="01">01</option>
	..... cut .....
	<option value="58">58</option>
	<option value="59">59</option>
	</select>
	<select name="Time_Meridian">
	<option value="am" selected>AM</option>
	<option value="pm">PM</option>
	</select>
		


html_table

Description

Will dump an array of data into an HTML table. The cols attribute determines how many columns will be in the table. The table_attr, tr_attr and td_attr values determine the attributes given to the table, tr and td tags. If tr_attr or td_attr are arrays, they will be cycled through. trailpad is the value put into the trailing cells on the last table row if there are any present..

Arguments

Example

	PHP 
=============================
<?php
require('class.template.php');
$template_object = new Template_Lite;
$template_object->assign('data',array(1,2,3,4,5,6,7,8,9));
$template_object->assign('tr',array('bgcolor="#eeeeee"','bgcolor="#dddddd"'));
$template_object->display('index.tpl');
?> TEMPLATE ============================= { html_table loop=$data }
{ html_table loop=$data cols=4 table_attr='border="0"' }
{ html_table loop=$data cols=4 tr_attr=$tr } OUTPUT ============================= <table border="1"> <tr><td>1</td><td>2</td><td>3</td></tr> <tr><td>4</td><td>5</td><td>6</td></tr> <tr><td>7</td><td>8</td><td>9</td></tr> </table> <table border="0"> <tr><td>1</td><td>2</td><td>3</td><td>4</td></tr> <tr><td>5</td><td>6</td><td>7</td><td>8</td></tr> <tr><td>9</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr> </table> <table border="1"> <tr bgcolor="#eeeeee"><td>1</td><td>2</td><td>3</td><td>4</td></tr> <tr bgcolor="#dddddd"><td>5</td><td>6</td><td>7</td><td>8</td></tr> <tr bgcolor="#eeeeee"><td>9</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr> </table>


html_textbox

Description

Will insert a textbox into the template.

Arguments

Example

	TEMPLATE
	=============================
	{ html_textbox name="test" rows="4" columns="60" }

	OUTPUT
	=============================
	<TEXTAREA NAME="test" ROWS="4" COLS="60"></TEXTAREA>
	


in_array

Description

Will search an array for a matching value and return the set returnvalue if a match is found.

Arguments

Example

	TEMPLATE
	=============================
	<input type="checkbox" name="test" value="1" { in_array array=$atribname[$i] match=$atrib returnvalue="CHECKED" }>

	OUTPUT
	=============================
	<input type="checkbox" name="test" value="1" CHECKED>
	


mailto

Description

Will insert a mailto: link and optionally encodes them into the template. Encoding e-mails makes it more difficult for web spiders to lift e-mail addresses off of your site.

Arguments

Example

	TEMPLATE
	=============================
	{ mailto address="me@example.com" }
	{ mailto address="me@example.com" text="send me some mail" }

	OUTPUT
	=============================
	<a href="mailto:me@example.com" >me@example.com</a>
	<a href="mailto:me@example.com" >send me some mail</a>


math

Description

Will allow the template designer to do math equations in the template. Any numeric template variables may be used in the equations, and the result is printed in place of the tag. The variables used in the equation are passed as parameters, which can be template variables or static values. +, -, /, *, abs, ceil, cos, exp, floor, log, log10, max, min, pi, pow, rand, round, sin, sqrt, srans and tan are all valid operators. Check the PHP documentation for further information on these math functions.

If you supply the special "assign" attribute, the output of the math function will be assigned to this template variable instead of being output to the template.

Arguments

Example

	TEMPLATE
	=============================
	{ math equation="(( x + y ) / z )" x=2 y=10 z=2 }
	{ math equation="x + y" x=4.4444 y=5.0000 format="%.2f" }

	OUTPUT
	=============================
	6
	9.44


popup_init

Description

{popup_init} must be called once at the top of any page you plan on using the {popup} function. {popup} is an integration of overLib, a library used for popup windows. These are used for context sensitive information, such as help windows or tooltips.

overLib was written by Erik Bosrup, and the homepage/download is located at http://www.bosrup.com/web/overlib/.

Example

	TEMPLATE
	=============================
	<head>
{* popup_init must be called once at the top of the page *}
{popup_init src="javascripts/overlib.js"}
</head>


popup

Description

Will allow the template designer to create javascript popup windows. {popup_init} MUST be called first for this to work.

Arguments

Example

	TEMPLATE
	=============================
	{* popup_init must be called once at the top of the page *}
		{popup_init src="/javascripts/overlib.js"}
	{* create a link with a popup window when you move your mouse over *}
		<a href="mypage.html" {popup text="This link takes you to my page!"}>mypage</a>
	{* you can use html, links, etc in your popup text *}
		<a href="mypage.html" {popup sticky=true caption="mypage contents" 
		text="<ul><li>links</li><li>pages</li><li>images</li></ul>" 
		snapx=10 snapy=10}>mypage</a>
    


resize_image

Description

This plugin can create actual thumbnail images from images on the server or through a URL. A completed image tag referencing the thumbnail image will be created. The thumbnails are date stamped and will be automatically recreated after 5 days have passed or the number of days specified by the daystokeep argument.

Arguments

Example

	TEMPLATE
	=============================
	{resize_image img_src="/thumbnails/" directory="/html/mysite/ad_images/" thumbdir="/html/mysite/thumbnails/" filename="Myfile.jpg" xscale="150" yscale="200" thumbname="thumb_"}

	OUTPUT
	=============================
	image
	


Home