Expand my Community achievements bar.

SOLVED

Best Practice for getting user info for display

Avatar

Level 5

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

1 Accepted Solution

Avatar

Correct answer by
Level 10

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)

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

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)

Avatar

Level 5

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