Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new

Learn more

View all

Sign in to view all badges

Handlebars Context Scope

Level 4
Level 4

Hi All,

I'm trying to get a context named userAdmin from within the handlebars framework for AEM Social Communities. The userAdmin context checks if the logged in user is a member or a moderator.

We already have this code within /libs/social/console/components/hbs/sitenavbar/sitenavbar.hbs at line number 54. With the below userAdmin context the Administration link appears only if the logged in user is a moderator/Community Admin

                {{#if userAdmin}}
                    <li><a href="{{adminUrl}}">{{i18n "Administration"}}</a></li>


I'm not able to fetch the same userAdmin context within /libs/social/messaging/components/hbs/messagebox/buttons.hbs at line number 36 where I want to the new message button only if the logged in user is a moderator/Community Admin

                {{#if userAdmin}} //Here the context is not available within the buttons.hbs
                    <input type='submit' class='actionbuttons' id='newMessageButton' name='{{properties.replyURL}}' value='{{i18n "+ New Message"}}' />

Could you please help me to figure out a way to get the context available in sitenavbar to any other SCF component like messagebox or forums. I've also tried using options like {{../userAdmin}} and {{@rootuserAdmin}}

 Any suggestion or help would be great.

Thanks, Bharath

1 Reply
Community Advisor
Community Advisor

This data (or getter) is exposed through the SocialComponent for this resource type. Only few objects are implicit available globally. So you need to define your own social component and implement (or extend existing component if some bundle exports it) such a getter. You can refer to the example scf projects (for example here) in github or look also in the adobe documentation.

You can find all objects available in the context of the current path by appending .social.json (e.g. /content/community-components/en/forum/jcr:content/content/ will expose all the variables (context) that can be used inside the template. answered at a stack overflow page: