• 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

md_5

Well-known member
#1
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:
Code:
.rankAdmin {
    background: url("@imagePath/xenforo/gradients/tab-unselected-25px-light.png") #xxxxxx;
    border: 1px solid #xxxxxx;
}
to EXTRA.css
Add something like:
Code:
<xen:if is="{xen:helper ismemberof, $user, 6}">
    <span class="rank rankDeveloper">Developer</span>
</xen:if>
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)
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>
</xen:if>
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
#2
Group styling is actually available as a CSS class. The CSS selector is always:

Code:
.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:

http://xenforo.com/community/resources/display-a-random-banner.375/

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