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

XF 1.2 Usergoup Indicator in Message

Discussion in 'Styling and Customization Questions' started by pjfry, Sep 5, 2013.

  1. pjfry

    pjfry Active Member

    Hi there,

    in the message template, there is an indicator for staff like this one:

    Code:
    {xen:if '{$message.is_staff}
    Is there something similar to this to indicate every usergroup, for example guests?

    Something like:

    Code:
    {xen:if '{$message.is_guest}
    OR

    Code:
    {xen:if '{$message.usergrozp == "1"}
    Thanks Benny
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Use the xen helper ismemberof.

    Check the conditional statement resource in my signature.
     
    pjfry likes this.
  3. pjfry

    pjfry Active Member

    Hi Brogan,

    thank sfor your help, but it is not working as intend maybe you find the problem. here is my code:

    Code:
    <li id="{$messageId}" class="message {xen:if $message.isDeleted, 'deleted'} {xen:if '{$message.is_staff}', 'staff'} {xen:if $message.isIgnored, ignored} <xen:if is="{xen:helper ismemberof, $user, 5}"> premium</xen:if>" data-author="{$message.username}">
    I posted a message with a user whos primary usergroup is premium (ID = 5). So I thought that now for all messages this user write the css class premium should be added. But it isn't, and I don't know why.

    Maybe you have an idea?

    Thanks!

    benny
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Look at the rest of the code.
    You have used < instead of {, etc.
     
    Chris D and pjfry like this.
  5. pjfry

    pjfry Active Member

    Thanks @Brogan but I think I now nearly tried every possibility but it doesn't work so far :(

    When I try the code posted above the template will save but not work as intend when I change < instead of { and a mix of it or ... I tried now every constellation I think but always the template won't save because of a syntax error :(

    Maybe you can show me the correct code?

    thanks Benny
     
  6. pjfry

    pjfry Active Member

    Do nobody have any idea? I tried now a lot of things like:

    Code:
    <xen:if is="{xen:helper ismemberof, $message, 5}"> premium</xen:if>
    Code:
    <xen:if is="{xen:helper ismemberof, $user, 5}"> premium</xen:if>
    Code:
    {xen:if is="{xen:helper ismemberof, $user, 5}", premium}
    Code:
    <xen:if is="{xen:helper ismemberof, $message, 5}"> premium</xen:if>
    Code:
    {xen:if is="{xen:helper ismemberof, $message, 5}", premium}
    Code:
    <xen:if is="{xen:helper ismemberof, $message.user, 5}"> premium</xen:if>
    Code:
    {xen:if is="{xen:helper ismemberof, $message.user, 5}", premium}
    But nothing worked for me :(
     
  7. Steve F

    Steve F Well-Known Member

    Code:
    <xen:if is="{xen:helper ismemberof, $user, 9}" > Content </xen:if>
     
  8. Chris D

    Chris D XenForo Developer Staff Member

    That would work, Steve, but there's another variation of IF statements that work. They're much better for inline conditionals.

    Specifically @pjfry is trying to add conditionals on this line:

    Code:
    <li id="{$messageId}" class="message {xen:if $message.isDeleted, 'deleted'} {xen:if '{$message.is_staff}', 'staff'} {xen:if $message.isIgnored, ignored}" data-author="{$message.username}">
    And what @Brogan was alluding to, is spot on. Look at the rest of the code. This is what one of the if statements look like:

    Code:
    {xen:if $message.isDeleted, 'deleted'}
    None of your variations are quite like that... First, there's no "xen:if is" it's just "xen:if" for inline curly conditionals.

    So the correct answer, is:

    Code:
    {xen:if '{xen:helper ismemberof, $user, 5}', 'premium'}
    The structure of a curly if conditional is:

    {xen:if '{{condition to check}}', '{{result if true}}', '{{result if false}}'}

    The last parameter is optional.
     
    Steve F likes this.

Share This Page