Smarty Tags

Overview

Exponent provides many custom tools you can use in building your module views.  Some of these tools are pretty simple, and some are much more complex. Here we'll list our custom tags and a few of the standard built-in ones.  With a little studying, you may be able to create your own.

Smarty Tags Guide

attribution function

{attribution} returns an attribution based on the site configuration format for the selected user. It accepts a parameter of 'user_id' for a user id or 'user' for a user name. ...

backlink function

{backlink} returns a link to the previous page in history.  It accepts a parameter of 'distance' to go back more than one page (default). ...

br function

Probably the simplest of these handy little smarty snippets is the {br} plugin. Seems simple enough. What it does is add in a line break in your TPLs. However, first it checks to see if the theme you are using has XHTML on or off. It will then write the break with the appropriate syntax. Pretty handy if you want to ensure your doc is valid html. ...

bytes modifier

Returns the number formated in bytes, kilobytes, or megabytes based on the size of the number.   {$size|bytes} would return an appropriate number followed by bytes, kb, or mb. ...

chain function (DEPRECATED)

Chaining was a way to combine the functionality of one module (or controller) with another. However, it has been replaced by the showmodule function.  When using the {chain} plugin within your views, you're actually hard-coding your module in to the view of another module . Here's an example: ...

clear function

Another simple little plugin, this is very useful to ensure there is no overlap in content. Here's the code: ...

css block

If you need a way to throw some CSS in a view, you may use the "css" smarty block plugin to pull it out when that view is called upon and automatically put the css in the header (where it should be).   ...

cycle function

This isn't Exponent specific, but if you haven't visited the Smarty Docs yet, you should really know about it. Here's a sample piece of code: ...

export_pdf_link

{export_pdf_link} creates a link which brings up a copy of the current item as a pdf in a popup view.  This is only functionial when the optional 'dompdf' package is installed. ...

format_date modifier

$date|format_date will format the selected date for display.  The default format is the Display Date format from site configuration, but you may also use the 'format' parameter ...

get_user function

{get_user} gives you quick information about a user, either the logged in user or a selected user.  The default is to simply print out the username of the current logged on user, but it accepts these params: ...

gettext modifier

{gettext} translates the selected text through the Exponent language subsystem. ...

gettxtlist function

{gettxtlist} translates the selected comma-delimited text through the Exponent language subsystem. This is mainly useful for lists passed to controls. ...

help function

{help} build a help link on the page.  There are two basic variations to this function both of which display a link which opens a new page from the docs/help site as set in site configuration. ...

ical_link

{ical_link} is used to create a link to the ical feed if the feature is turned on in the events module, otherwise it displays nothing.  Though most params are not necessary, you could pass a: ...

icon function

{icon} gives you quick access to display an icon and have it act as a button without having to write out the urls yourself.  Here's a snippet: ...

img function

{img} allows you to easily process a graphic file through the phpThumb thumbnail generator.  Available parameters are any allowed by phpThumb ...

include

When your tpl files begin to get fairly complex, or if you just really want to be efficient with your code, using "include" allows you to break a piece of your code out into a separate file: ...

link function

{link} simplifies building a link url based on the site 'SEF' setting and passed parameters. ...

nbsp function

{nbsp} returns one or more non-breaking spaces ( ). ...

pagelinks function

{pagelinks} is used to place paginations links on the page based on the module pagination configuration settings.  Though most params are not necessary, you could pass a: ...

permissions block

{permissions} is used to enclose those links which are based on permissions which will not be displayed to normal users (without permissions). ...

plural function/modifier

{plural} returns either a 'singular' or 'plural' from of a phrase based on the 'count' parameter.  It is available as either a function for modifier though each operates with different parameters. ...

printer_friendly_link function

{printer_friendly_link} creates a link which brings up a printer friendly popup view. ...

relative_date modifer

The relative_date modifier returns the passed date as a relative date such as 3 hours ago, etc... ...

rss_link function

{rss_link} is used to create a link to the rss feed if the feature is turned on, otherwise it displays nothing.  This is NOT to be confused with the older {rsslink} function which spit out the non-sef_url link.  Though most params are not necessary, you could pass a: ...

script block

The {script} block allows you to easily embed javascript within the template and allow it to be placed in the appropriate location on the page and also minimized if that feature is turned on.  In a basic since the {script} block operates like the {css} block where it can be passed a 'src' parameter with the path to a script file.  It requires a 'unique' identifer parameter and can aid the loading of YUI or jQuery by passing 'yui3mods' or 'jquery' set or with a comma-separated list of modules.  Otherwise, you can place javascript code within the block, HOWEVER we recommend you enclose it in {literal} tags to prevent confusion when using open/close brackets, etc... ...

selectobjects function

{selectobjects} is a wrapper to select objects from the database.  It accepts the same parameters as the expDatabase->selectObjects method. ...

selectvalue function

{selectvalue} is a wrapper to select a value from the database.  It accepts the same values as the expDatabase->selectValue method: ...

showmodule function

Showmodule is a way to combine the functionality of one module (or controller) with another. It replaces the {chain} function.  When using the {showmodule} plugin within your views, you're actually hard-coding your module in to the view of another module . Here's an example: ...

smarty.const variable

The "smarty.const" tag has a number of uses.  Here are some sample snippets: ...

subscribe_link function

{subscribe_link} is used to create a link allowing the user to subscribe or unsubscribe to content updates to the module if the e-alerts feature is turned on, otherwise it displays nothing.    Though most params are not necessary, you could pass a: ...

summarize modifier

$text|summarize attempts to strip and possibly truncate the selected text.  There are two parameters: ...

uniqueid function

Unique ID will cause Exponent to generate a unique identifier for you on the fly. This can be used with TPLs that have a depending javascript file.  You can set a prefix by passing the 'prepend' parameter or have the id assigned to a variable by passing the 'assign' parameter.  If you have multiple instances of the same script being used on the same page, you will avoid errors by doing the following: ...

username modifier

Returns the username for the selected user id. ...