• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Template / CSS Syntax - Get group metadata


Well-known member
Right now I have a badge system that looks like:

In order to give a user these badges I need to do 3 things.
Add color: xxxxxx; to the users custom CSS.
Add something like:
.rankAdmin {
    background: url("@imagePath/xenforo/gradients/tab-unselected-25px-light.png") #xxxxxx;
    border: 1px solid #xxxxxx;
to EXTRA.css
Add something like:
<xen:if is="{xen:helper ismemberof, $user, 6}">
    <span class="rank rankDeveloper">Developer</span>
To the message_user_info template
Ideally I would like to scrap EXTRA.css, and then add a check into the template, something like (pseudo code)
<xen:if is="{xen:helper ismemberof, $user, 6}">
    $group = getGroup(6);
    <span class="rank" style="background: url("@imagePath/xenforo/gradients/tab-unselected-25px-light.png") #(substring $.group.customCSS); border: 1px solid #(substring $.group.customCSS);">$group.Name</span>
I know this would be perhaps better suited to a plugin, but I can't find any good info on Xen CSS / template syntax so:
  • Is it possible to look up a group via a template?
  • Can I get this groups name?
  • Can I get this groups custom css?
  • Can I get a substring of a string?
  • Can I loop through all groups?

Jake Bunce

XenForo moderator
Staff member
Group styling is actually available as a CSS class. The CSS selector is always:

.username .style3
"3" is the group_id of the group. So you can apply a group's styling by simply referencing that class in your HTML code.

Otherwise group information (such as title) is not available to the templates. But for your purposes (and in regards to your pseudo code) you can use xen:set to make your life easier when defining your template code. Example using xen:set:


Can I get a substring of a string?
Not with template syntax, no.