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

XF 1.2 How Do I Get Usergroup Count into a Template?

Discussion in 'XenForo Questions and Support' started by MJD, Jan 10, 2014.

  1. MJD

    MJD Member

    Been trying to customize my Xenforo install and I'd like to show the # of users in a particular UserGroup, say USERGROUP-ZZZ, on my forum home page.

    How would I go about showing this in a template? I have a template modification in the template "node_category_level_1" which is basically this:

    <xen:if is="{$category.node_id} == 1">
    Count: {$category.discussion_count)
    <xen:include template="my_custom_template" />

    The modification above works great, I just can't figure out how to get the usergroup count into a variable and from the database, onto the "my_custom_template".

    I know how to grab the data from phpAdmin using an SQL statement (SELECT COUNT(`user_group_id`) FROM xf_user_group WHERE `user_group_id` = 7) but I'm not entirely sure how to expose this into a template.

    Any ideas? Or is this a complicated undertaking? Thank you for any help!
  2. Brogan

    Brogan XenForo Moderator Staff Member

    You will need to develop an add-on to extend the code and pass the value to the template.
    MJD likes this.
  3. MJD

    MJD Member

    Thanks Brogan, I will hit the "How to Create an Add-On" tutorial and see if I can figure it out.
  4. thedude

    thedude Well-Known Member

    Search viewParams to get started
    MJD likes this.

Share This Page