XF 1.5 Add text if content available

abdfahim

Well-known member
I want to add a heading to the custom fields in postbit. So I want div.myTest be ONLY visible if any custom user field is visible in the postbit area (i.e. if the user fills any custom field).

In the below modification of message_user_info template, div.myTest remains always visible, even if there is no custom field.

I am not sure how exactly I should do that. Anybody can help please?

Code:
         <xen:contentcheck>
          //////// OTHER DISPLAY OPTIONS /////////

         <xen:if is="@messageShowCustomFields AND {$user.customFields}">
            <xen:hook name="message_user_info_custom_fields" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
                <div class="div.myTest">CUSTOM FIELDS</div>
                <xen:foreach loop="$userFieldsInfo" key="$fieldId" value="$fieldInfo">
                    <xen:if is="{$fieldInfo.viewable_message} AND ({$fieldInfo.display_group} != 'contact' OR {$user.allow_view_identities} == 'everyone' OR ({$user.allow_view_identities} == 'members' AND {$visitor.user_id}))">
                        <xen:if hascontent="true">
                            <dl class="pairsJustified userField_{$fieldId}">
                                <dt>{xen:helper userFieldTitle, $fieldId}:</dt>
                                <dd><xen:contentcheck>{xen:helper userFieldValue, $fieldInfo, $user, {$user.customFields.{$fieldId}}}</xen:contentcheck></dd>
                            </dl>
                        </xen:if>
                    </xen:if>
                </xen:foreach>
              
            </xen:hook>
            </xen:if>
            </xen:contentcheck>
 
Last edited:

abdfahim

Well-known member
ah, got it .. sweet :D ....

Code:
<xen:contentcheck>
          //////// OTHER DISPLAY OPTIONS /////////

         <xen:if is="@messageShowCustomFields AND {$user.customFields}">
            <xen:hook name="message_user_info_custom_fields" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
                <xen:if hascontent="true">
                <div class="div.myTest">CUSTOM FIELDS</div>
                <xen:contentcheck>
                <xen:foreach loop="$userFieldsInfo" key="$fieldId" value="$fieldInfo">
                    <xen:if is="{$fieldInfo.viewable_message} AND ({$fieldInfo.display_group} != 'contact' OR {$user.allow_view_identities} == 'everyone' OR ({$user.allow_view_identities} == 'members' AND {$visitor.user_id}))">
                        <xen:if hascontent="true">
                            <dl class="pairsJustified userField_{$fieldId}">
                                <dt>{xen:helper userFieldTitle, $fieldId}:</dt>
                                <dd><xen:contentcheck>{xen:helper userFieldValue, $fieldInfo, $user, {$user.customFields.{$fieldId}}}</xen:contentcheck></dd>
                            </dl>
                        </xen:if>
                    </xen:if>
                </xen:foreach>
                </xen:contentcheck>
                </xen:if>
            </xen:hook>
            </xen:if>
            </xen:contentcheck>
 
Top