 |
Flat-Frog - the faster compiling PHP template engine |
Custom Functions
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
- assign
This is the name of the variable that the output will be assigned into.
Example
EXAMPLE
=============================
<% capture assign=variable %>
<% $variable|upper %>
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>
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
- name (optional)
The name of the counter.
- start (optional)
The number to start counting from. Default is 1.
- skip (optional)
The interval to count by. Default is 1.
- direction (optional)
The direction to count in. Either up
or down
.
- print (optional)
Whether or not to print the value. Default is true.
- assign (optional)
The template variable that the value will be assigned to.
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>
Description
Cycle will alternate between multiple values on each recurring call.
Arguments
- name (optional)
The name of the cycle.
- values
The values to cycle through. This can be either a comma separated list or an array of values.
- print (optional)
Whether to print the value or not. The default is to print the value.
- advance (optional)
Whether to advance to the next value or not. The default is to advance the value.
- delimiter (optional)
The delimiter to use in separating the values in the values
argument. The default is a comma.
- assign (optional)
The template variable that the value will be assigned to.
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>
Description
Will insert a checkbox into the template.
Arguments
- name
The name of the checkbox.
- value (optional)
The value for the checkbox.
- checked (optional)
Whether or not the checkbox is checked. Must equal value
to be considered true.
Example
TEMPLATE
=============================
<% html_checkbox name="test" %>
OUTPUT
=============================
<INPUT TYPE="CHECKBOX" NAME="test">
Description
Will insert an image (optionally resized) into the template.
Arguments
- url
The URL of the image.
- width (optional)
The desired width of the image.
- height (optional)
The desired height of the image.
- border (optional)
The desired border width of the image.
- alt (optional)
Alternate text for the image.
- limit (optional)
If set to true, this will cause the image to be resized to the above height and width if the above height and width are smaller than the real height and width.
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">
Description
Will insert a text box (or optionally a password box) into the template.
Arguments
- name
The name of the input box.
- value (optional)
The value of the input box.
- size (optional)
The visible size of the input box.
- length (optional)
The maximum length of the input box.
- password (optional)
Whether or not to be a password input box.
Example
TEMPLATE
=============================
<% html_input name="test" %>
OUTPUT
=============================
<INPUT TYPE="TEXT" VALUE="" NAME="test">
Description
Will create a list of options for a select
in the HTML template.
Arguments
- options
The array of values used to generate the options from.
- selected (optional)
The default value to be selected.
- name (optional)
The name of the select. If present, the plugin will create the select
in the template as well as the options
.
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>
Description
Will insert a radio button into the template.
Arguments
- name
The name of the radio button.
- value (optional)
The value of the radio button.
- checked (optional)
Whether the box is checked or not. Must equal value
to be considered true.
Example
TEMPLATE
=============================
<% html_radio name="test" %>
OUTPUT
=============================
<INPUT TYPE="RADIO" NAME="test">
Description
Will insert a textbox into the template.
Arguments
- name
The name of the textbox.
- rows (optional)
The number of rows in the textbox.
- columns (optional)
The number of columns in the textbox.
- value (optional)
The value of the textbox.
Example
TEMPLATE
=============================
<% html_textbox name="test" rows="4" columns="60" %>
OUTPUT
=============================
<TEXTAREA NAME="test" ROWS="4" COLS="60"></TEXTAREA>
Home