XF 2.2 Looking for an <if> command for custom user field

DaveL

Well-known member
I've got a custom userfield, however if it's not filled out out shows the empty styling.
alliance.webp

Looking for an <if> command to wrap the following in so the empty box doesn't show if this custom user field hasn't been completed.

Code:
<div style="background-color: blue; color: #FFF; padding: 2px; border: 2px solid #ff0000; border-radius: 5px 5px 5px 5px;">
    <center>{$user.Profile.custom_fields.AllianceName}</center>
</div>

Would really apprectiate any help.
 
XF code already does this by default.

How are you displaying the custom user field?

You just need to check the style property and have the field viewable in message user info.
 
Thanks Brogan,

All my custom fields are enclosed in a drop down box in the message macros.

20.webp

And then opened

10.webp

I'm looking to display a custom userfield outside of this. So far i've managed to do that, but I can't style it, as the style always remains whether someone has completed that field or not. I was hoping there might be a conditional I can use such as 'If this custom user field has not been completed, do not display'.
Hope that makes sense!
 
Try wrapping it in <xf:if contentcheck="true"> ... </xf:contentcheck>
Thanks @Brogan

If I try
Code:
<xf:if contentcheck="true">
<div style="background-color: blue; color: #FFF; padding: 2px; border: 2px solid #ff0000; border-radius: 5px 5px 5px 5px;">
    <center>{$user.Profile.custom_fields.AllianceName}</center>
</div></xf:contentcheck>

It comes back with the following error when I try to save
Template tags are not well formed. Tag contentcheck was found when expecting if. - Template modifications: public:message_macros
 
I pasted the wrong thing.

It should have been a closing if but there is also a second part of the content check.

Have a look in the message_macros template to see how it's used.
 
I pasted the wrong thing.

It should have been a closing if but there is also a second part of the content check.

Have a look in the message_macros template to see how it's used.
Thanks, Think this is getting a bit beyond me.
Looked at the message_macros and the only content check I can see is
Code:
<xf:if contentcheck="true">
                <div class="message-userExtras">
                <xf:contentcheck>
                    <xf:if is="$extras.register_date">
                        <dl class="pairs pairs--justified">
                            <dt>{{ phrase('joined') }}</dt>
                            <dd>{{ date($user.register_date) }}</dd>
                        </dl>
                    </xf:if>

Having a guess, should mine look like:

Code:
<xf:if contentcheck="true">

<div style="background-color: blue; color: #FFF; padding: 2px; border: 2px solid #ff0000; border-radius: 5px 5px 5px 5px;">
<xf:contentcheck>
    <center><xf:if is="$user.Profile.custom_fields.AllianceName"></center>

</div>

</xf:if>
 
Last edited:
Got it working :D

Code:
<xf:if contentcheck="true">
     <div style="background-color: blue; color: #FFF; padding: 2px; border: 2px solid #ff0000; border-radius: 5px 5px 5px 5px;">
        <center> <xf:contentcheck>{$user.Profile.custom_fields.AllianceName}</xf:contentcheck></center>
    </div>
</xf:if>
 
Top Bottom