Smarty Functions - 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/NB9ZDAFCLBCQ/microsoftteams-image-288-29.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/NB9ZDAFCLBCQ/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>This section outlines all the Vanilla-specific Smarty functions made available for use in your Smarty templates.</p><p>You are also able to use the <a href="http://www.smarty.net/docsv2/en/language.custom.functions.tpl" rel="nofollow noreferrer ugc">built-in Smarty functions</a> in your template.</p><h2 data-id="function%3A-debug_vars">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{debug_vars}</code></h2><p>Opens up the Smarty debug console in a popup window. This will show you all of the data available to the smarty template. This data matches the <code class="code codeInline" spellcheck="false" tabindex="0">data</code> attribute on the page’s controller.</p><p>Additional data can be easily added by using the <code class="code codeInline" spellcheck="false" tabindex="0">setData()</code> method. See the <a href="https://success.vanillaforums.com/kb/articles/246-theme-hooks" rel="nofollow noreferrer ugc">themehooks documentation</a> for detail.</p><h3 data-id="usage">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{debug_vars} </pre><h2 data-id="function%3A-asset">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{asset}</code></h2><h3 data-id="usage-1">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{asset name="string" id="string" tag="string" class="string"} </pre><p>Renders an asset from the controller.</p><p>Assets in Vanilla are containers for different sets of content. The content of each of these asset containers is variable depending on the page. The content of each asset is not currently configurable via the template.</p><p>Vanilla’s asset names are Head, Foot, Content and Panel. Your template will need to contain the Head, Foot and Content assets. The Panel asset is optional, but you’ll likely want to at least include it in the Profile, EditProfile and Conversation sections as it has important functionality in those sections that are not included in the Content asset.</p><h3 data-id="parameters">Parameters</h3><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/883/GAPHOQ2GVWEW.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/883/GAPHOQ2GVWEW.png" alt="image.png" height="494" width="1634" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <h2 data-id="function%3A-breadcrumbs">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{breadcrumbs}</code></h2><h3 data-id="usage-2">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{breadcrumbs homelink="string" hidelast=boolean} </pre><p>Render a breadcrumb trail for the user based on the page they are on.</p><h3 data-id="parameters-1">Parameters</h3><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/005/4NPXY822K5JK.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/005/4NPXY822K5JK.png" alt="image.png" height="380" width="1644" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <h2 data-id="function%3A-custom_menu">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{custom_menu}</code></h2><h3 data-id="usage-3">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{custom_menu format="string" wrap="string"} </pre><p>A bucket for addon menu items. Adds links depending on which addons are enabled.</p><h3 data-id="parameters-2">Parameters</h3><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/413/VAJV9KSY4S5B.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/413/VAJV9KSY4S5B.png" alt="image.png" height="310" width="1640" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <h2 data-id="function%3A-event">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{event}</code></h2><h3 data-id="usage-4">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{event name="string"} </pre><p>Fire an event with the specified <code class="code codeInline" spellcheck="false" tabindex="0">name</code>. Learn more about <a href="https://success.vanillaforums.com/kb/articles/245-event-and-handlers" rel="nofollow noreferrer ugc">events</a> in Vanilla.</p><h3 data-id="parameters-3">Parameters</h3><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/753/5YDILQGSG1WU.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/753/5YDILQGSG1WU.png" alt="image.png" height="192" width="1646" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <h2 data-id="function%3A-homepage_title">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{homepage_title}</code></h2><h3 data-id="usage-5">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{homepage_title} </pre><p>Writes the site title to the page. You can change the site title from the ‘Banner’ settings page in the dashboard.</p><h3 data-id="parameters-4">Parameters</h3><p><em>This tag does not take any parameters.</em></p><h2 data-id="function%3A-t">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{t}</code></h2><h3 data-id="usage-6">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{t c="string" d="string"} </pre><p>Output a translatable string with an optional default.</p><h3 data-id="parameters-5">Parameters</h3><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/490/G5XDWO1C3008.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/490/G5XDWO1C3008.png" alt="image.png" height="286" width="1644" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <h2 data-id="function%3A-include_file">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{include_file}</code></h2><h3 data-id="usage-7">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{include_file name="string"} </pre><p>Inserts the contents the specified file into the template. The file must be in the same directory as the Smarty template file. Especially useful for inserting html headers or footers into a Smarty template.</p><h3 data-id="parameters-6">Parameters</h3><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/063/4Q2FN7Z859WW.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/063/4Q2FN7Z859WW.png" alt="image.png" height="162" width="1650" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <h2 data-id="function%3A-link">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{link}</code></h2><h3 data-id="usage-8">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{link path="string" text="string" notag=boolean format="string" withdomain=boolean} </pre><p>Takes a route and prepends the web root (expects <code class="code codeInline" spellcheck="false" tabindex="0">/controller/action/params</code> as <code class="code codeInline" spellcheck="false" tabindex="0">path</code>).</p><h3 data-id="parameters-7">Parameters</h3><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/537/MZO003QFR3XW.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/537/MZO003QFR3XW.png" alt="image.png" height="758" width="1644" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <h2 data-id="function-*_link">Function <code class="code codeInline" spellcheck="false" tabindex="0">{*_link}</code></h2><p>We’ve created dedicated Smarty functions for a number of links to Vanilla pages that make it easier to build your forum’s navigation.</p><h3 data-id="usage-9">Usage</h3><p>Here’s the basic syntax, where * is the link type.</p><pre class="code codeBlock" spellcheck="false" tabindex="0">{*_link wrap="string" text="string" format="string"} </pre><p>They take all of the same parameters as a <code class="code codeInline" spellcheck="false" tabindex="0">{link}</code> but have the <code class="code codeInline" spellcheck="false" tabindex="0">path</code> and <code class="code codeInline" spellcheck="false" tabindex="0">string</code> prefilled. These include</p><h3 data-id="parameters-8">Parameters</h3><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/202/4U1CBYVZ0AT0.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/202/4U1CBYVZ0AT0.png" alt="image.png" height="766" width="1640" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <h3 data-id="available-*_link-functions">Available <code class="code codeInline" spellcheck="false" tabindex="0">{*_link}</code> functions</h3><h4 data-id="function%3A-bookmarks_link">Function: {bookmarks_link}</h4><p>Link to the My Bookmarks page.</p><h4 data-id="function%3A-categories_link">Function: {categories_link}</h4><p>Link to the categories page.</p><h4 data-id="function%3A-category_link">Function: {category_link}</h4><p>Link to the current category page.</p><h4 data-id="function%3A-dashboard_link">Function: {dashboard_link}</h4><p>Link to the dashboard.</p><h4 data-id="function%3A-discussions_link">Function: {discussions_link}</h4><p>Link to the discussions page.</p><h4 data-id="function%3A-drafts_link">Function: {drafts_link}</h4><p>Link to the drafts page.</p><h4 data-id="function%3A-activity_link">Function: {activity_link}</h4><p>Link to the recent activity page.</p><h4 data-id="function%3A-forum_root_link">Function: {forum_root_link}</h4><p>Link to the forum root page.</p><h4 data-id="function%3A-home_link">Function: {home_link}</h4><p>Link to the home page.</p><h4 data-id="function%3A-inbox_link">Function: {inbox_link}</h4><p>Link to the inbox.</p><h4 data-id="function%3A-mydiscussions_link">Function: {mydiscussions_link}</h4><p>Link to the My Discussions page.</p><h4 data-id="function%3A-nomobile_link">Function: {nomobile_link}</h4><p>Link for showing the desktop version of the site.</p><h4 data-id="function%3A-photo_link">Function: {photo_link}</h4><p>Link to the session’s user profile that displays as the user’s avatar.</p><h4 data-id="function%3A-profile_link">Function: {profile_link}</h4><p>Link to session’s user profile. The link text is the username. Includes a notification count.</p><h4 data-id="function%3A-signin_link">Function: {signin_link}</h4><p>If there is a valid session, this outputs a signout link, otherwise a signin link.</p><h4 data-id="function%3A-signinout_link">Function: {signinout_link}</h4><p>If there is a valid session, this outputs a signout link, otherwise a signin link.</p><h4 data-id="function%3A-user_link">Function: {user_link}</h4><p>Link to session’s user profile. The link text is this username. Does not include a notification count.</p><h2 data-id="function%3A-logo-mobile_logo">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{logo}</code> & <code class="code codeInline" spellcheck="false" tabindex="0">{mobile_logo}</code></h2><h3 data-id="usage-10">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{logo} {mobile_logo} </pre><p>Writes the site logo to the page. You can change the site logo from the ‘Banner’ settings page in the dashboard.</p><h3 data-id="parameters-9">Parameters</h3><p><em>These tags does not take any parameters.</em></p><h2 data-id="function%3A-module">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{module}</code></h2><h3 data-id="usage-11">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{module name="string" ... } </pre><p>This is a super handy little function that renders any module in Vanilla. It instantiates the specified module class, sets the properties specified in the function’s parameters and calls the toString() function of the module.</p><p>The available parameters differ depending on module itself and the available modules depend on which addons are enabled. If a module is contained in an addon, the addon must be enabled in order for the module to render (a common gotcha).</p><p>There are many modules available in Vanilla and in its addons. They can be found in the modules directory of an application or addon. <a href="https://docs.vanillaforums.com/developers/framework/modules.html.md" rel="nofollow noreferrer ugc">Learn more about modules.</a></p><h3 data-id="parameters-10">Parameters</h3><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/451/PKL87GEA0WSC.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/451/PKL87GEA0WSC.png" alt="image.png" height="490" width="1640" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <p>You can set any property of a module by specifying it as a parameter as long as that property has a setter method or has a visibility of public.</p><h3 data-id="example">Example</h3><p>Here’s an example of a tag that renders the Promoted Content Module, a module that can filter discussions based on role, rank, score, category, or the promoted reaction:</p><pre class="code codeBlock" spellcheck="false" tabindex="0">{module name="PromotedContentModule" Selector="role" Selection="Developer,Administrator" Limit="12" Group="3"} </pre><h2 data-id="block%3A-permission">Block: <code class="code codeInline" spellcheck="false" tabindex="0">{permission}</code></h2><h3 data-id="usage-12">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{permission require="string"} Foo {/permission} </pre><p>Only output content if the current user has the specified permission.</p><h3 data-id="parameters-11">Parameters</h3><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/671/0CDZSAZ4CZIY.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/671/0CDZSAZ4CZIY.png" alt="image.png" height="176" width="1646" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <h2 data-id="function%3A-pocket">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{pocket}</code></h2><h3 data-id="usage-13">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{pocket name="string"} </pre><p>Writes a pocket to the page. Pockets placed in the template in this way should have their location set to ‘custom’. You can edit this setting from the ‘Pockets’ settings page in the dashboard.</p><h3 data-id="parameters-12">Parameters</h3><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/150/6R9LNOQBB6R2.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/150/6R9LNOQBB6R2.png" alt="image.png" height="174" width="1638" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <h2 data-id="function%3A-searchbox">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{searchbox}</code></h2><h3 data-id="usage-14">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{searchbox placeholder="string"} </pre><p>Writes the search box to the page.</p><h3 data-id="parameters-13">Parameters</h3><p>ParameterTypeDefaultDescription<code class="code codeInline" spellcheck="false" tabindex="0">placeholderstringSearch</code>Optional input box placeholder text</p><h2 data-id="function%3A-searchbox_advanced">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{searchbox_advanced}</code></h2><h3 data-id="usage-15">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{searchbox_advanced} </pre><p>Writes an <code class="code codeInline" spellcheck="false" tabindex="0">AdvancedSearchModule</code> to the page. This functionality is only the available to the Vanilla Cloud customers with the <code class="code codeInline" spellcheck="false" tabindex="0">AdvancedSearch</code> plugin enabled. More details about advanced search can be found in the <a href="https://docs.vanillaforums.com/help/addons/advanced-search/#using-advanced-search" rel="nofollow noreferrer ugc">help documentation</a>.</p><p>The advanced searchbox smarty tag does not currently offer a <code class="code codeInline" spellcheck="false" tabindex="0">placeholder</code> attribute. It’s placeholder value can be changed by <a href="https://docs.vanillaforums.com/developer/locales/" rel="nofollow noreferrer ugc">editing the locale key</a> <code class="code codeInline" spellcheck="false" tabindex="0">SearchBoxPlaceHolder</code>.</p><h2 data-id="function-banner_image_url">Function <code class="code codeInline" spellcheck="false" tabindex="0">{banner_image_url}</code></h2><h3 data-id="usage-16">Usage</h3><p>This function is easiest used inside of an <code class="code codeInline" spellcheck="false" tabindex="0">img</code> tag or an inline <code class="code codeInline" spellcheck="false" tabindex="0">background-image</code> style. These examples will likely require additional styles to be formatted properly.</p><pre class="code codeBlock" spellcheck="false" tabindex="0"><img src="{banner_image_url}" alt="Hero Image" /> <!-- Or as an background --> <div style="background-image(url('{banner_image_url}'))"></div> </pre><h2 data-id="function%3A-text">Function: <code class="code codeInline" spellcheck="false" tabindex="0">{text}</code></h2><h3 data-id="usage-17">Usage</h3><pre class="code codeBlock" spellcheck="false" tabindex="0">{text code="string" default="string"} </pre><p>Returns the custom text from a theme’s options page. <a href="https://docs.vanillaforums.com/developer/smarty/functions/developer/theming/themeoptions/" rel="nofollow noreferrer ugc">Learn more about how to configure your theme options.</a></p><h3 data-id="parameters-14">Parameters</h3><div class="embedExternal embedImage display-large float-none"> <div class="embedExternal-content"> <a class="embedImage-link" href="https://us.v-cdn.net/6030677/uploads/325/4XHBNU9XJ0WO.png" rel="nofollow noreferrer noopener ugc" target="_blank"> <img class="embedImage-img" src="https://us.v-cdn.net/6030677/uploads/325/4XHBNU9XJ0WO.png" alt="image.png" height="276" width="1636" loading="lazy" data-display-size="large" data-float="none"></img></a> </div> </div> <p><br></p> </article> </main>