Flat-Frog - 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 %>
	<% $variable|upper %>
	


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>
	


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>
	


html_checkbox

Description

Will insert a checkbox into the template.

Arguments

Example

	TEMPLATE
	=============================
	<% html_checkbox name="test" %>

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


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_radio

Description

Will insert a radio button into the template.

Arguments

Example

	TEMPLATE
	=============================
	<% html_radio name="test" %>

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


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>
	


Home