Smarty Modifiers - HL Vanilla Community
<main> <article class="userContent"> <div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/0DJKK4STW63R/microsoftteams-image-288-29.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/0DJKK4STW63R/microsoftteams-image-288-29.png" alt="MicrosoftTeams-image (8).png" height="108" width="1356" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <p>Smarty modifiers can be applied to variables, custom functions or strings. You can use a modifier by adding a | (pipe) after the element you wish to modify and adding the modifier name. Modifiers can also accept parameters which are separated by a : (colon). <em>These parameters must follow the order of their appearance in the signature</em>.</p><p>Vanilla supports the built-in Smarty modifiers as documented on the Smarty site, and has created a few more for you to use in your templates. <a href="http://www.smarty.net/docsv2/en/language.modifiers.tpl" rel="nofollow noreferrer ugc">Learn more about Smarty modifiers from the Smarty site.</a>.</p><h2 data-id="modifier%3A-asset_url">Modifier: asset_url</h2><p>Converts a string to an asset url. Solves the problem of trying to using a relative path when Vanilla exists in a subfolder.</p><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/092/BGRAZ5P2ANEN.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/092/BGRAZ5P2ANEN.png" alt="image.png" height="334" width="1628" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <h3 data-id="example">Example</h3><p>In the following example, if the asset_url modifier was not specified, the image would not work if Vanilla existed in a subfolder. It also adds the domain name to the url and appends the theme version number.</p><pre class="code codeBlock" spellcheck="false" tabindex="0"><img alt="My logo" src="{"/themes/MyTheme/design/images/my-logo.png"|asset_url:true:true}" > </pre><h2 data-id="modifier%3A-translate">Modifier: translate</h2><p>Translates a string into the selected locale’s definition.</p><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/809/O82AD4BKA4BV.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/809/O82AD4BKA4BV.png" alt="image.png" height="174" width="1642" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <h3 data-id="example-1">Example</h3><p>This example outputs the breadcrumbs, where the home link text is the translated ‘Forum’ definition. <a href="https://docs.vanillaforums.com/functions/breadcrumbs.html.md" rel="nofollow noreferrer ugc">Learn more about the breadcrumbs tag.</a></p><pre class="code codeBlock" spellcheck="false" tabindex="0">{breadcrumbs homelink="Forum"|translate} </pre><p><br></p> </article> </main>