2 Add a Bookmarked Groups Panel to the Person Profile Shared by Michael Allen, Valorous Church 6 months ago 12.0 General Beginner What are we building? This recipe will show you how to add a panel to the person profile that will show a list of all the groups that you follow with an indicator to show if the person being viewed is in any of those groups. I can make a badge to show "In Group", why would I need this? If you were to make a badge for every group a staff member could want to see at a glance, you will end up with a lot of badges. Also, not all staff members would care about the same groups. The idea was to replicate the functionality of the "Bookmarked Attributes" panel on the profile page. This will allow your staff to choose the groups that they want to see at a glance, without having to go to the groups tab and scroll through a long list. How? Add a HTML Block to the person profile page. Edit the block settings Check the box for "Enabled Lava Commands" > "RockEntity" Select "Person" from the dropdown under "Context > Entity Type" Set the Block's content to the following: //- Find all of the groups I am following {% following where:'EntityTypeId == 16' expression:'PersonAlias.PersonId == {{ CurrentPerson.Id }}' securityenabled:'false' %} {% assign groupIds = followingItems | Select:'EntityId' %} {% endfollowing %} //- Go through the list of groups from above and lookup the data for each group {% capture results %} [ {% for groupId in groupIds %} {% assign group = groupId | GroupById %} {% if group %} { 'Id': {{ group.Id | ToJSON }}, 'Name': {{ group.Name | ToJSON }}, //- Is the person in the group? 'Member': {{ group.Members | Select:'PersonId' | Contains:Context.Person.Id | ToJSON }} }, {% endif %} {% endfor %} ] {% endcapture %} {% assign results = results | FromJSON %} //- Sort the list {% assign results = results | Sort:'Name' %} //- Format the display table <div class='panel panel-persondetails'> <div class='panel-heading'> <h3 class='panel-title pull-left'><i class='fa fa-bookmark'></i> Bookmarked Groups</h3> </div> <div class='grid grid-panel'> <table class='table table-hover'> <tr> <th style='padding-left:24px'>Group Name</th> <th>Is Member</th> </tr> {% for group in results %} <tr onclick='window.location.href="/people/groups?GroupId={{ group.Id }}"' style='cursor:pointer'> <td style='padding-left:24px'>{{ group.Name }}</td> <td>{% if group.Member %}<i class='fa fa-check'></i>{% endif %}</td> </tr> {% endfor %} </table> </div> </div> Change Log 2022-02-11 - Initial Version 2022-03-19 - Updated Lava to be v12 compatible
Tony Visconti Reply 10 days ago (edited 10 days ago) We were running into some performance issues on the profile page because of how many groups we have. I went ahead and rewrote the lava in my first comment to use a sql query instead of entity commands: https://pastebin.com/tTU5yyqv
Tony Visconti Reply 4 months ago (edited 10 days ago) Thank you for sharing, nice use of the existing "following groups" functionality.When I implemented the recipe I made a tweaksFor me the panel heading needed the clearfix class to display properly i.e.<div class='panel-heading clearfix'>The link to each group page was also not working for me: "/people/groups?GroupId={{ group.Id }}"' so I updated it to /Group/{{ group.Id }}Add a link to documentation and a link to Following page as rollover items in the panel headingAdded a Following By Entity Block to the My Settings > Following page so that individuals could quickly see all groups they were followingDisplayed only bookmarked groups where the individual is a member of instead of showing all groupsHere is a screenshot of where I landed:https://www.screencast.com/t/vqm7oYyMZ3MoHere is a copied of the revised lavahttps://pastebin.com/tTU5yyqvI'd like to do more to display groups differently where the group is inactive or where the individual is inactive in the group.