Highlighted

Retrieve latest content from AEM Repository

Avatar

Avatar

hanscy

Avatar

hanscy

hanscy

20-12-2018

Hi guys,

I got a requirement to be able to retrieve content from AEM repository on a web page once it is published, ie. retrieve the latest publish content.

Using the JavaScript Use API is somehow possible as well, however once the latest content published it won't display directly on the client/user machine as the dispatcher cache the content and we will need to flush the dispatcher cache to be able to retrieve the new content.

Doing that is somehow ineffective if we have a large number of content inside the repository already.

any sorts of suggestions / best practice how to do it?

Thanks!

Replies

Highlighted

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

5.6K

Likes

961

Correct Answer

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

5.6K

Likes

961

Correct Answer

1.1K
kautuk_sahni
Community Manager

07-01-2019

Jörg Hoh​ Any help on this one?

Highlighted

Avatar

Avatar

Gaurav-Behl

MVP

Total Posts

1.1K

Likes

226

Correct Answer

281

Avatar

Gaurav-Behl

MVP

Total Posts

1.1K

Likes

226

Correct Answer

281
Gaurav-Behl
MVP

07-01-2019

Javascript Use API is typically used by HTL which is a server-side language.

Use client side jquery ajax ($.ajax) or Apache Sling Dynamic Include or any other similar framework

Adobe Experience Manager Help | Set up Sling Dynamic Include in AEM

GitHub - Cognifide/Sling-Dynamic-Include: Sling Dynamic Include

http://api.jquery.com/jquery.ajax/

Highlighted

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

910

Correct Answer

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

910

Correct Answer

1.0K
Jörg_Hoh
Employee

07-01-2019

Hi,

I read your question, but I don't understand it. I understood that you want to fetch the latest published content, but the second paragraph doesn't make sense to me. Can you rephrase your question?

Thanks,

Jörg

Highlighted

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K
smacdonald2008

07-01-2019

I agree with Joerg - your question is not clear. You want to query latest published content. What purpose is this for? Do you want to track pages that are published for reporting purposes?

Highlighted

Avatar

Avatar

hanscy

Avatar

hanscy

hanscy

07-01-2019

Hi Joerg,

Thanks for the reply Joerg!

What I wanted to say on the second paragraph is basically one of the possibility to fetch the latest published content from the JCR. However it is not a really good solution (ineffective)  as it is using the JS Use API which is a server-side language and potentially put a heavily load on the server.

so to summarise it, the question is basically, is there any other solutions that we can implement to fetch the latest published content so that the user can get suggestions on the latest published article once the article is published?

Highlighted

Avatar

Avatar

hanscy

Avatar

hanscy

hanscy

07-01-2019

the purpose is not to track pages that are being published, the purpose is to promote / display the latest published articles to users.

Highlighted

Avatar

Avatar

edubey

Total Posts

1.5K

Likes

264

Correct Answer

392

Avatar

edubey

Total Posts

1.5K

Likes

264

Correct Answer

392
edubey

07-01-2019

Yes, you can achieve it. But in this case your this particular request has to pass from dispatcher without caching.

gauravb10066713​ has already mentioned few recommended approach which is used to tackle this like SDI, Ajax

Highlighted

Avatar

Avatar

hanscy

Avatar

hanscy

hanscy

07-01-2019

Hi,

Thanks for that! what will be the AJAX solutions looks like? do you have any example?

I am keen to look at the solution example if you have any with AJAX.

Highlighted

Avatar

Avatar

edubey

Total Posts

1.5K

Likes

264

Correct Answer

392

Avatar

edubey

Total Posts

1.5K

Likes

264

Correct Answer

392
edubey

07-01-2019

I don't have the details of your requirement but on a high level, you will have to create an endpoint in your aem (using servlet). These endpoint will be responsible for sending response with updated content. From front-end you will be requesting these endpoint and consume the response.

Some helpx articles you can refer to

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

https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

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