Best Practice for getting user info for display | Community
Skip to main content
Level 4
February 1, 2016
Solved

Best Practice for getting user info for display

  • February 1, 2016
  • 2 replies
  • 1530 views

Hi all. 

In certain templates, I'm running into a case where I'm going to have to access the same information for several users multiple times. Given an ID, I'm wondering if there is a best practice for accessing their information (namely: email, name, phone number, and a couple other data points). Ideally I would be able to store that in a sightly object and access it like ${user.name} ${user.email} (and on).

For some more background, this is for a news syndication system, and the user information will be used all over the place (article templates, news list components, author archive pages). My initial thought was to use a WCMUsePojo, although, I'm running into an unrelated issue with my basic use class not correctly reading in a passed id parameter, which is just generally making me consider other options.

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

You can do this use case in a Sightly component. One way you can do this (and we have done this in custom AEM tools we develop) is to create the JCR SQL API. If you have  users under a path - say /home/users - query under that path and use the ID value to select the user node.

Use JCR SQL2 to perform the query operation. After you query - then read the node property values and return the values to the front part of the Sightly component where they are displayed.

We have a related AEM article that will point you in the right direction:

https://helpx.adobe.com/experience-manager/using/sightly_querybuilder.html

(this uses QueryBuilder API to query - you can use that API as well instread of JCR SQL2)

2 replies

smacdonald2008
smacdonald2008Accepted solution
Level 10
February 1, 2016

You can do this use case in a Sightly component. One way you can do this (and we have done this in custom AEM tools we develop) is to create the JCR SQL API. If you have  users under a path - say /home/users - query under that path and use the ID value to select the user node.

Use JCR SQL2 to perform the query operation. After you query - then read the node property values and return the values to the front part of the Sightly component where they are displayed.

We have a related AEM article that will point you in the right direction:

https://helpx.adobe.com/experience-manager/using/sightly_querybuilder.html

(this uses QueryBuilder API to query - you can use that API as well instread of JCR SQL2)

varshsr
Level 5
February 2, 2016

Also pls ensure that you are giving enough cache/design considerations in case of these dynamic data on pages and are user specific to avoid stale content