<HTML ><HEAD ><TITLE >Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Smarty Manual" HREF="index.html"><LINK REL="UP" TITLE="Basic Syntax" HREF="language.basic.syntax.html"><LINK REL="PREVIOUS" TITLE="Variables" HREF="language.syntax.variables.html"><LINK REL="NEXT" TITLE="Attributes" HREF="language.syntax.attributes.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Smarty Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="language.syntax.variables.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 3. Basic Syntax</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="language.syntax.attributes.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="language.syntax.functions" ></A >Functions</H1 ><P > Every Smarty tag either prints a <A HREF="language.variables.html" >variable</A > or invokes some sort of function. These are processed and displayed by enclosing the function and its <A HREF="language.syntax.attributes.html" >attributes</A > within delimiters like so: <TT CLASS="literal" >{funcname attr1='val1' attr2='val2'}</TT >. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN262" ></A ><P ><B >Example 3-3. function syntax </B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="programlisting" >{config_load file='colors.conf'} {include file='header.tpl'} {insert file='banner_ads.tpl' title='Smarty is cool'} {if $logged_in} Welcome, <font color="{#fontColor#}">{$name}!</font> {else} hi, {$name} {/if} {include file='footer.tpl' ad=$random_id}</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ><P ></P ><UL ><LI ><P > Both <A HREF="language.builtin.functions.html" >built-in functions</A > and <A HREF="language.custom.functions.html" >custom functions</A > have the same syntax within templates. </P ></LI ><LI ><P >Built-in functions are the <SPAN CLASS="bold" ><B CLASS="emphasis" >inner</B ></SPAN > workings of Smarty, such as <A HREF="language.function.if.html" ><TT CLASS="varname" >{if}</TT ></A >, <A HREF="language.function.section.html" ><TT CLASS="varname" >{section}</TT ></A > and <A HREF="language.function.strip.html" ><TT CLASS="varname" >{strip}</TT ></A >. There should be no need to change or modify them. </P ></LI ><LI ><P >Custom functions are <SPAN CLASS="bold" ><B CLASS="emphasis" >additional</B ></SPAN > functions implemented via <A HREF="plugins.html" >plugins</A >. They can be modified to your liking, or you can create new ones. <A HREF="language.function.html.options.html" > <TT CLASS="varname" >{html_options}</TT ></A > and <A HREF="language.function.popup.html" ><TT CLASS="varname" >{popup}</TT ></A > are examples of custom functions. </P ></LI ></UL ><P > See also <A HREF="api.register.function.html" ><TT CLASS="varname" >register_function()</TT ></A > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="language.syntax.variables.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="language.syntax.attributes.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Variables</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="language.basic.syntax.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Attributes</TD ></TR ></TABLE ></DIV ></BODY ></HTML >