Handlebars Context Scope

Avatar

Avatar

Bharath_valse

Avatar

Bharath_valse

Bharath_valse

28-03-2017

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>
                {{/if}}

Problem

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"}}' />
                {{/if}}

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar

Amit_Kumar

MVP

Avatar

Amit_Kumar

MVP

Amit_Kumar
MVP

04-05-2017

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/forum.social.json).This will expose all the variables (context) that can be used inside the template. answered at a stack overflow page: http://stackoverflow.com/questions/43082235/aem-social-communities-handlebars-context