Smarty PlugIns
Emvicy comes with several plug-ins for Smarty.
modifier
- see also official Smarty Documentation on this topic: www.smarty.net/docs/en/plugins.modifiers.tpl
smarty_modifier_centToEuro
converts eurocent into euro (1000 => 10,00 €)
smarty_modifier_centToEuro(mixed $iValue = 0, bool $bShowEuroSymbol = true) : string
Examples
Default
{1000|centToEuro}
10,00 €
Do not display the euro symbol
{1000|centToEuro:false}
10,00
smarty_modifier_dateformat
converts a timestamp into the requested format. Per default the format is ISO Date and time.
smarty_modifier_dateformat(int $iTimestamp, string $sFormat = 'Y-m-d H:i:s') : string
Examples
default
{1763119198|dateformat}
2025-11-14 12:19:58
format into Y-m-d
{1763119198|dateformat:"Y-m-d"}
2025-11-14
smarty_modifier_filesize
converts Byte into Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte.
smarty_modifier_filesize(string $sByte, int $iDecimals = 2) : string
Examples
{1234|filesize}
1.21K
{9876543210|filesize}
9.20G
smarty_modifier_gtext
This Smarty modifier helps instantly translating Strings into other Languages using the PHP Extension gettext.
smarty_modifier_gtext(string $sString = '', string $sDomain = 'term', string $sLang = '') : string
Requirements
- requires installation of php module:
php{Version}-intl(and maybelibicu52) - You need to name the Place of so called
Translationtables. That means the place where yourTranslationfolderreside.
Simply place this code snippet somewhere into your configs
$aConfig['APP'] = array(
// path
'GETTEXT' => '/var/www/html/translation',
// default language
'LANG' => 'de_DE'
);
The structure of the Translationtables must follow the official declaration, e.g.
/var/www/html/translation/
└── de_DE
└── LC_MESSAGES
├── backend.mo
└── backend.po
Examples
In all Examples, the File backend (backend.mo) will be consulted for Translation.
Simple Output of a String
{'Frontend'|gtext:'backend'}
{'Frontend'|gtext:'backend':'de_DE'}
Output using sprintf to set values dynamically
{'(changed Menutitel; Original is `%s`)'|gtext:'backend'|sprintf:'123'}
{'Page %s of %s Pages'|gtext:'backend'|sprintf:'7':'100'}
Output with Translation into a certain Language
{'Desktop'|gtext:'backend':'it_IT'}
smarty_modifier_hasValue
checks whether there is value or not; Everything is a value, except null and empty string ''.
smarty_modifier_hasValue($mValue) : bool
Examples
{0|hasValue}
true
{null|hasValue}
false
{''|hasValue}
false
smarty_modifier_highlight_html
returns <tag>-encapsulated, highlighted html markup.
smarty_modifier_highlight_html(string $sMarkup = '', string $sTag = 'code', bool $bPurify = false) : string
Examples
default
{'<h1>Title</h1><p>Test</p>'|highlight_html:"span"}
<span><<span style="color:#d02">h1</span>>Title</<span style="color:#d02">h1</span>><<span style="color:#d02">p</span>>Test</<span style="color:#d02">p</span>></span>
<h1>Title</h1><p>Test</p>
with auto-repair broken html; option true
{'<h1>Title</h1><span>Test'|highlight_html:"span":true}
<span><<span style="color:#d02">h1</span>>Title</<span style="color:#d02">h1</span>><<span style="color:#d02">p</span>>Test</<span style="color:#d02">p</span>></span>
<h1>Title</h1><p>Test</p>
smarty_modifier_shrink
truncates a string evenly distributed at the front and back to the specified total length and inserts a string (filler) in between.
smarty_modifier_shrink(string $sString = '', int $iMaxChars = 255, string $sFiller = '…') : string
Examples
default
{'This is a very long, meaningless text used for demonstration purposes only'|shrinkLink:30}
This is a ver…purposes only
using a custom filler string
{'This is a very long, meaningless text used for demonstration purposes only'|shrinkLink:30:"_*_"}
This is a ver_*_purposes only
smarty_modifier_parsedown
converts "markdown" syntax into markup.
smarty_modifier_parsedown(string $sMarkdown = '') : string
Example
{"# Hello World\n- one\n- two\n- three"|parsedown}
Result
<h1>Hello World</h1>
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul>
Emvicy