Template Syntax: XenForo Tags

Unmaintained Template Syntax: XenForo Tags

The xen:topctrl tag allows you to define HTML that is placed within the container next to the top breadcrumbs.

Attributes
The top control tag does not have any attributes, and relies on the HTML provided within the tags for the functionality.

Example
HTML:
<xen:topctrl><a href="{xen:link 'reports/closed'}" class="callToAction"><span>{xen:phrase closed_reports}</span></a></xen:topctrl>

This will create the following view (in the report center):
Screen Shot 2016-02-03 at 3.50.35 PM.webp
  • Like
Reactions: Myke623
The xen:container tag is utilized to set container variable data.

Attributes
  • var (required)
    • The var attribute is used to define which variable will receive the contained HTML.
Example

For a broad example on how to use the xen:container tag, you can see @Brogan's guide here: https://xenforo.com/community/resources/using-variables-in-templates.5034/update?update=18416

The following is a quick sample that allows you to add HTML to the container without requiring an editor or your own code (besides the HTML you pass it):
HTML:
<xen:container var="$head.robots">
    <meta name="robots" content="noindex" />
</xen:container>

The output will include the contained HTML right before the end of the head tag in the HTML source.
  • Like
Reactions: Myke623
The xen:description tag is utilized to overwrite and set the meta description for individual pages.

Attributes
  • skipmeta
    • The skipmeta attribute is a boolean flag as to whether or not the meta description should be displayed. Setting it to true will turn off the display, while false or not defining it will leave the display on.
Example
Code:
<xen:description>The meta description is meta and talks about itself.</xen:description>
This will output the following in the PAGE_CONTAINER template:
HTML:
<meta name="description" content="The meta description is meta and talks about itself." />

Code:
<xen:description skipmeta="true"></xen:description>
This will prevent any meta description from being displayed.

Notes
  • The meta description is limited to 200 words.
The xen:avatar is a simpler and easier to read version of {xen:helper avatar, ...} (documentation forthcoming).

Attributes
  • user (required)
    • The user attribute is required and requires an array of user information that is used to fetch and build the avatar HTML.
  • size
    • The size attribute specifies which of three pre-defined sizes are used within the HTML. The permissible values for the size attribute are s, m, l for 48px, 96x and 192px sized avatars, respectively. If no size attribute is specified, or an invalid value is provided, the system will default to m.
  • img
    • If the img attribute is set to true the returned HTML will be an img tag, otherwise, it will be a span tag with the users avatar as the background image.
  • class
    • The class attribute allows you to specified the class(es) on which should be applied to the surrounding link. Note: you should include a space in your classes.
  • href
    • The href allows you to specify a link to be included in the returned HTML.
Example
Code:
                            <xen:avatar user="$visitor" size="m" class="OverlayTrigger" href="{xen:link account/avatar}" />

Notes
  • In most cases, xen:avatar is used as a self-closing tag. However, it may be used with an appropriate end tag and the content will be included after the avatar HTML and within the surrounding link.
The xen:require tag is utilized to include outside JavaScript sources that do not exist within templates and to include CSS templates.

Attributes
  • css
    • The css attribute is utilized to include necessary CSS into the page upon load. Unlike xen:include, xen:require adds its output into the header of the page. In the case of CSS, it also compiles them into a single call to reduce HTTP requests per page.
  • js
    • The js attribute is used to add in a JavaScript file from your server into your page.
Example
Code:
<xen:require css="account.css" />
<xen:require js="js/xenforo/personal_details_editor.js" />

Notes
  • xen:require is a self closing tag.
  • Either the css or js attribute must be defined.
  • All css requires must end in .css.
The xen:sidebar tag is designed to inform the software that the page you are currently viewing (or rather, the one being viewed using the template) that a sidebar is to exist on the page. Examples of this can be seen in both the Resource Manager and the forum index.

Attributes
The xen:sidebar tag does not utilize any attributes, and its functionality resides within the content of the tags.

Example
Code:
<xen:sidebar>
I'm in the sidebar!
</xen:sidebar>

This will create a sidebar with a visitor panel and the text "I'm in the sidebar!"

To create a sidebar without the visitor panel, you would use a xen:container parameter to opt out of displaying the panel. This will produce the same output as above without the visitor panel displayed. The Resource Manager's sidebar utilizes this technique. The xen:container documentation is coming soon.
Code:
<xen:sidebar>
    <xen:container var="$noVisitorPanel">1</xen:container>
     I'm in the sidebar!
</xen:sidebar>
The xen:edithint tag is used to inform the software of templates to include in the edit template window as extra tabs. These templates are useful when editing the template, but are not directly included in the template itself. This tag is a self closing tag.

Attributes
  • template (required)
    • Name of the template that could help while attempting to edit the template. This must be a valid XenForo template.
Example
Code:
<xen:edithint template="xenforo_alert.css" />
The xen:map tag is used in conjunction with the xen:include tag. It is used to copy a variable to another. This is useful when using xen:include when the template you are including uses different variable names for the same data.

Attributes
  • from (required)
    • The from attribute is used to define the source variable.
  • to (required)
    • The to attribute is used to define the destination variable.
Example
Code:
                    <xen:include template="helper_birthday_input">
                        <xen:map from="$visitor" to="$user" />
                    </xen:include>

Developer Note: This is handled via xen:include's class, and doesn't have a class of its own.
The xen:include tag is used to include another template into the file at the location of inclusion. This is useful when you have multiple templates that can be reused or is necessary for your template. When editing a template, any included templates are available as tabs to allow easy editing of all the used templates.

Attributes
The xen:include tag will take the following attributes:
  • template (required)
    • The template attribute is used to instruct XenForo which template you would like for inclusion. This must be a valid template name.
Notes
  • The xen:include tag can be a self-closing tag, and for the most part, is used this way within XenForo. It shouldn't be used as a self-closing tag when you need to map a variable (use xen:map) or set a variable (use xen:set) for use within the included template. Please see the documentation for those tags for more information on their uses.
  • Any data and variables available to the template will be available in all included templates.
Example
Self-closing example:
Code:
<xen:include template="navigation_sidebar.css" />

Example with xen:map used:
Code:
                    <xen:include template="helper_birthday_input">
                        <xen:map from="$visitor" to="$user" />
                    </xen:include>
The xen:title tag is used to set the title of the current page, as seen by this resource if you look at the tab/browser window. The contents of this tag come before your community's name in the title tag of the HTML.

Attributes
The xen:title tag takes no attributes.

Example:
Code:
<xen:title>Template Syntax: XenForo Tags</xen:title>
This is the internal code that will be run by the XenForo Resource Manager for this resource. The direct translation will output the following tag (in the header section):
HTML:
<title>Template Syntax: XenForo Tags | XenForo Community</title>
Back
Top Bottom