[Solved] Experience View: Show link only for a particular user group


#1

How can I display a hyperlink for only one user group using handlebars in my view HTML? I tried the below but it doesn’t seem to quite work.

        {{#each experience.user.experienceGroups}}
          {{#eq experience.user.experienceGroups[@index] 'Administrator'}}   
            <li><a href="https://mylink.com">Admin only link</a></li>
          {{/eq}}
        {{/each}}

Any ideas?

Regards

Ashley


#2

Try this. When looping, the context of the current item is available at this. -

        {{#each experience.user.experienceGroups}}
          {{#eq this.name 'Administrator'}}   
            <li><a href="https://mylink.com">Admin only link</a></li>
          {{/eq}}
        {{/each}}

#3

Awesome, that worked! Thanks, you always know the answer…


#4

Happy to help. Keep the questions coming. :slight_smile:


#5

Just curious if this is the optimal method for managing Group access? In a true commercial scale multi-tenant deployment it seems that this approach might get a bit unwieldy.