Functions and blocks

Besides variables you can also use functions. A function looks exactly like a variable, but without the dollar sign. The following code is for example the function to create a link to the web version of en email:

{webversion}

Some functions have an open and a close tag. These block functions are used to modify or mark the text that is encapsulated inside the tags:

{mailonly}
    Click <a href="{webversion}">here</a> to view this mail in your browser
{/mailonly}

The {mailonly} block is used to mark a piece of code to only be visible in the mail version of the message. Would this template be displayed via the web (because someone clicks on the web version link), the code inside the tags will not be rendered. In the above example we cleverly use the {mailonly} block to hide the web version link if the user already views the mail in his or her browser.

Available functions in the Publisher

The list of available functions is long. There are a lot of functions that are built-in Smarty functions, and a number of Copernica-only functions:

Function name Description
{assign} Assign a value to a variable
{capture} Capture blocks and store in a variable
{condition} Conditional block based on a JavaScript expression
{counter} Counter (ascending/descending)
{cycle} Cycle between two values
{eval} To evaluate a variable as a template
{feed} Load an external RSS feed
{fetch} Import externally hosted content
{foreach} Iterate over an array
{if} Conditional block
{in_miniselection} Mark text that is only rendered if subprofile belongs to a miniselection
{in_selection} Mark text that is only rendered if profile belongs to a selection
{ldelim} Left curly bracket
{literal} Mark literal block in which curly brackets are permitted
{linkfile} Link to a file
{linkpdf} Link to a PDF document
{loadfeed} Load external RSS feed
{loadfile} Load file into mailing
{mailonly} Mark text that is only rendered in the mail (not on the web)
{math} Calculations and mathematical equations
{rawcapture} Like {capture}, but without html escaping
{strip} Remove whitespace
{survey} Display a survey
{rdelim} Right curly bracket
{textformat} Text formatting
{unsubscribe} Unsubscribe link
{webform} Render a webform
{webonly} Mark text that is only rendered on the web (not in an email)

More information