Joe Link
Well-known member
We place new members in a trial group until they hit criteria for full membership. Within conversations, we want to show a small single line notice to full members if there's a single participant in the trial group, or a larger notice with a list of members in this group if there's multiple members in the trial group.
I trial-and-error'd my way to working code, but it seems inefficient to use one foreach just for counting (to determine which notice to display) and another for displaying the list (when applicable). Is there a better way?
I trial-and-error'd my way to working code, but it seems inefficient to use one foreach just for counting (to determine which notice to display) and another for displaying the list (when applicable). Is there a better way?
Code:
<xf:foreach loop="$recipients" value="$recipient" i="$exampleRecipientCount" if="($recipient.User.user_id != $xf.visitor.user_id) && $recipient.User.isMemberOf(<trial group ID>) && !$recipient.User.isMemberOf(<full member group ID>)"></xf:foreach>
<xf:if is="$exampleRecipientCount > 1">
Large List Notice
<ul>
<xf:foreach loop="$recipients" value="$recipient" if="($recipient.User.user_id != $xf.visitor.user_id) && $recipient.User.isMemberOf(<trial group ID>) && !$recipient.User.isMemberOf(<full member group ID>)">
<li>{$recipient.User.username}</li>
</xf:foreach>
</ul>
<xf:elseif is="$exampleRecipientCount == 1" />
Small Single Notice
</xf:if>