General Smarty
ONEsite uses the Smarty Templating language for rendering HTML entities. You can find out more information about standard smarty functions in the Smarty.net Documentation. ONEsite has created many custom functions and modifiers which can be found below.
Functions
Array
Builds a numeric array.
1 2 |
{array var="myArray" value="apples"} {array var="myArray" value="oranges"} |
Assoc
Builds an associative array.
1 2 |
{assoc var="myArray" key="myFruit" value="oranges"} {assoc var="myArray" key="yourFruit" value="apples"} |
BladeRunner
Verifies the user has entered a captcha prior to seeing the page.
1 |
{blade_runner} |
Cycle
Cycles through a list of values.
1 |
<div class="{cycle values="redFish,blueFish,oneFish,twoFish"}">Zebra Striping</div> |
Dar
Prints an array readable format.
1 |
{dar var=$myArray} |
Header
Sends a command to the page header.
1 |
{header command="Location: http://www.onesite.com"} |
Mailer
Sends an email.
1 |
{mailer to="example@example.com" from="example@onesite.com" subject="My Subject" body="My Body"} |
Set Cookie
Sets a cookie in the user’s browser.
1 |
{set_cookie name="myCookieName" value="test"} |
WebService
Calls a web service via a REST curl call.
1 2 |
{assoc var="params" key="param1" value="testing"} {web_service type="rest" assign="results" args=$params cache_ttl=600 url="http://www.example.com/rest/myService.php"} |
Modifiers
Standard PHP Functions
Standard PHP string functions can be used as modifiers.
1 2 3 |
{$myText|ucfirst} {$myText|strtolower} {$myText|explode:","} |
Standard PHP array functions can also be used as modifiers, but must have an @ sign to target the array.
1 2 3 4 |
{$myArray|@implode:","} {$myArray|@shuffle} {assign var="myKeys" value=$myArray|@array_keys} {assign var="currentKey" value=$myArray|@current}/code> |
AnchorUrls
Searches a text variable and links the urls.
1 |
{$myText|anchorurl} |
Capitalize
Capitalizes the first letter in a word.
1 |
{$myWord|capitalize} |
ScrubProfanity
Scrubs the profanity from a text block.
1 |
{$myText|scrub_profanity} |
StripTags
Strips html tags from a text block.
1 |
{$myText|strip_tags} |
Global Variables
Page
The $PAGE variable contains information and methods relating to the pageload.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
{$PAGE->IS_GROUP} {$PAGE->NODE_ID} {$PAGE->UID} {$PAGE->CURRENT_SITE_URL} {$PAGE->ORIGIN_URL} {$PAGE->NODE_BASE_URL} {$PAGE->CLIENT_VERSION} {$PAGE->IS_GROUP_MEMBER} {$PAGE->IS_FRIEND} {$PAGE->USER_RELATION} {$PAGE->add_javascript('http://www.example.com/javascript.js')} {$PAGE->add_css('http:/www.example.com/css.css')} {$PAGE->set_title('My Awesome Page')} {$PAGE->set_sub_title('My Awesome Page')} {$PAGE->add_head_html('<meta name="keywords" value="testing,testing2,testing3" />')} {$PAGE->set_body_class('myPage')} {$PAGE->setMetaDesc('description of my page')} {$PAGE->setMetaKeywords('keyword1,keyword2')} {$PAGE->isMobile()} |