XF 2.1 Add Custom Field to Member Card

penturners

Active member
I'd like to add a custom field named "name" (which I've defined and use in the member profile) to the member_tooltip just above the "joined" field.

I cobbled this together from examples here, but it doesn't work. I can't save the template due to "Unknown tag contentcheck encountered"

Code:
<div class="memberTooltip-blurb">
    <dl class="pairs pairs--inline">
        <dt>Name:</dt>
        <xf:contentcheck>
            <xf:if is="{$user.Profile.custom_fields.name}">
            {$user.Profile.custom_fields.name}
            </xf:if>
           </xf:contentcheck>
    </dl>
</div>

Thanks for any snippets or pointers you can provide.
 
Untested but try using <xf:if contentcheck="true"> ... </xf:if> outside the content check tags.

You likely don't need the if check inside then.
 
Thanks for moving the post. I overlooked that it was in the wrong forum.

Tried:
Code:
<div class="memberTooltip-blurb">
    <dl class="pairs pairs--inline">
    <dt>Name:</dt>
        <xf:if contentcheck="true">
            <xf:if is="{$user.Profile.custom_fields.name}">
                {$user.Profile.custom_fields.name}
             </xf:if>
        </xf:if>
    </dl>
</div>

Which throws the error "Tag must be a valid conditional using an is attribute or content checking. " on the second </xf:if> when I try to save it.
 
HTML:
<div class="memberTooltip-blurb">
    <dl class="pairs pairs--inline">
        <xf:if contentcheck="true">
            <dt>Name: </dt>
            <xf:contentcheck>
                {$user.Profile.custom_fields.name}
            </xf:contentcheck>
        </xf:if>
    </dl>
</div>
 
Many thanks! That works perfectly. I now see the logic.

Now, I'd like to allow users to enable or disable display of their name on the member card by ticking a box in their profile.

I wrapped the above code thusly:
HTML:
<xf:if is="!$user.Profile.custom_fields.hide_your_real_name">
    ...code from above...
</xf:if>

And it seems to work. Just want to confirm that this is the correct syntax to do this.
 
Back
Top Bottom