XF 1.2 Usergoup Indicator in Message

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
 
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
 
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
 
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 :(
 
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.
 
Top Bottom