Myko_P
7 years agoExpert
Custom component which shows the list of users with the specific role
Hi!
I got the custom component wich shows list of the users with the specific rank only. How can I customize it to show the list of the users with the specific role only?
Tried to change the first line to:
<#assign modId_request = rest("2.0","/search?q=" + "SELECT id FROM users WHERE role.name = 'Expert'"?url).data.items />
but got the following error:
InvalidReferenceException:The following has evaluated to null or missing: ==> rest("2.0","/search?q=" + "SELECT id FROM users WHERE role.name = 'Expert'"?url).data.items [in template "preview" at line 1, column 26]
The code of the original custom component wich works fine with the ranks is:
<#assign modId_request = rest("2.0","/search?q=" + "SELECT id FROM users WHERE rank.name = 'Модератор'"?url).data.items /> <div class="lia-panel lia-panel-standard meet-the-team"> <div class="lia-decoration-border"> <div class="lia-decoration-border-top"> <div> </div> </div> <div class="lia-decoration-border-content"> <div> <div class="lia-panel-heading-bar-wrapper"> <div class="lia-panel-heading-bar"> <span class="lia-panel-heading-bar-title">Наша команда</span> </div> </div> <div class="lia-panel-content-wrapper"> <div class="lia-panel-content"> <div class="UserList lia-component-users-widget-user-list"> <a name="user-list"> </a> <div class="t-data-grid"> <table class="lia-list-slim"> <tbody> <#list modId_request as modId> <#assign userData = restadmin("/users/id/${modId.id}").user /> <#assign userOnlineStatus = restadmin("/users/id/${modId.id}/sessions/online/latest").user_session.login_time /> <#assign userRanking = rest("/users/id/${modId.id}/ranking/").ranking /> <#assign userLogin = userData.login/> <#assign userID = userData.id/> <#assign userRankTitle = userRanking.name /> <#assign userAvatar = restadmin("/users/id/${modId.id}/profiles/avatar").image.url /> <tr class="lia-list-row lia-row-odd t-first"> <td class="userColumn lia-data-cell-primary lia-data-cell-text"> <div class="UserProfileSummary lia-user-item lia-user-info-group"> <div class="UserAvatar lia-user-avatar lia-component-common-widget-user-avatar"> <img class="lia-user-rank-icon-left" title="${userRanking.name}" alt="${userRanking.name}" src="${userAvatar}" /> </div> <div class="lia-user-attributes"> <div class="lia-user-name"> <span class="UserName lia-user-name lia-user-rank--------"> <a href="/t5/user/viewprofilepage/user-id/${userID}" class="lia-link-navigation lia-page-link lia-user-name-link" style="<#if userRanking.display.color?has_content>color:#${userRanking.display.color};</#if>"> <span class="<#if userRanking.display.bold=="true">login-bold</#if>">${userLogin}</span> </a> <img class="lia-user-rank-icon-left" title="${userRanking.name}" alt="${userRanking.name}" src="${userRanking.display.left_image.url}" /> <#if userOnlineStatus?has_content> <img id="online_id" title="Онлайн" src="http://club-test.volia.com/skins/images/C1123C835A20B8ECA12F46921268A279/new_design-e5d3bd17/images/online.png"> <#else> <img id="online_id" title="Оффлайн" src="http://club-test.volia.com/skins/images/0A8F08A2BEA86687F76C21BF3CF000B2/base/images/offline.png"> </#if> </span> </div> </div> </div> </td> </tr> </#list> </tbody> </table> </div> </div> </div> </div> </div> </div> <div class="lia-decoration-border-bottom"> <div> </div> </div> </div> </div>
Thanks!
Myko_P -
It should be roles.name not role.name.
<#assign modId_request = rest("2.0","/search?q=" + "SELECT id FROM users WHERE roles.name = 'Expert'"?url).data.items />