+1 vote
in Rock by TinaStephens (8.6k points)
edited

I need a badge to show not just current membership but also former membership (membership in a now-inactive group). Text should read "{{Name}} is in active cohort {{groupname}}" or "{{Name}} is in former cohort {{groupname}}."

  1. Current membership: color #207FB9.

  2. Former membership: color #464646.

  3. No membership: the light blue currently in use.

If possible can the badge be clickable, leading directly to the group page?

1 Answer

+1 vote
by TinaStephens (8.6k points)
edited
 
Best answer

Yes, you can use a lava badge to accomplish this.

It would be a badge with Entity Type- person; Badge Type-Lava.

In the Display Text place this lava then set Group Type to match your groups: (lava written by Mark Lee)

{% assign person = Person %}

{% sql personid:'{{person.Id | Default:0 }}' %}
SELECT
    g.Name as GroupName,
    g.Id as GroupId,
    g.IsArchived as GroupIsArchived,
    gm.IsArchived as MemberIsArchived
FROM GroupMember gm
JOIN [Group] g on g.Id = gm.GroupId
WHERE gm.PersonId = @personid
AND gm.GroupTypeId = 43
ORDER BY g.CreatedDateTime desc
{% endsql %}


{% assign size = results | Size %}
{% if size > 0 %}
    {% assign isActive = results | Where:'MemberIsArchived', 0 | Size %}
    {% if isActive > 0 %}
        {% assign color="#207FB9" %}
    {% else %}
        {% assign color="#464646" %}
    {% endif %}
{% else %}
    {% assign color="#cdeff8" %}
{% endif %}
     <div class="rockbadge rockbadge-icon"
        style="color:{{color}}"
        {% if size > 0 %}
        data-toggle="tooltip"
        data-html="true"
        data-trigger="hover focus click"
        data-placement="bottom"
        title="
        <div>
            {% for item in results %}
                <a href='https://admin.ccl.network/people/groups?GroupId={{item.GroupId}}' class='text-white' >
                {% if item.MemberIsArchived or item.GroupIsArchived %}
                    {{ Person.NickName }} is in former cohort {{ item.GroupName }}
                {% else %}
                    {{ Person.NickName }} is in active cohort {{ item.GroupName }}
                {% endif %}
                </a>
                {% if forloop.last == false %}
                <hr style='margin:5px;'>
                {% endif %}
            {% endfor %}
        </div>"
        {% endif %}>
        <i class="badge-icon fa fa-user-friends"></i>
    </div>
Welcome! Here you can ask questions and receive answers (hopefully) from other members of our team.
...