AEM Content Services: Using Sling and Node APIs to Provide Asset collections - Part 1 | AEM Community Blog Seeding

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,198 likes

Total Posts

6,375 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,198 likes

Total Posts

6,375 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

28-06-2021

BlogImage.jpg

AEM Content Services: Using Sling and Node APIs to Provide Asset collections - Part 1 by Perficient Blogs

Abstract

AEM is a proven framework for application delivery. Intuitive authoring features and HTL (formerly Sightly) driven content views make it easy to put together pages served from an AEM environment. The standard component strategy is great, but AEM offers more flexibility in how you use authored content. AEM Content Services allows authored content to be consumed via a headless CMS approach.


Content fragments offer discrete pieces of text and/or markup, and the Assets API provides references to your assets (including content fragments), all consumable by external apps as JSON.


In a mature DAM, you’ll find you have some images and fragments that are appropriate for external exposure and some that are not. AEM provides Asset Collections to expose specific assets and organize those assets in a simplified way. You can add assets or fragments to a collection from anywhere in the DAM and easily view all items within.


To provide these collections as a part of your headless CMS solution, you need to be able to display them in the JSON response provided by the Sling GET servlet. The out-of-the-box fragments implementation allows you to use content references, but that only serves a reference to the collection, it doesn’t provide the content within. Using the familiar Sling model + HTL component pattern, the code here enables access to the elements in a collection:

https://github.com/PRFTAdobe/AEM-Tutorials/blob/a7dda966be3843e9220d7b005ab3b307f7d51190/sample/core/src/main/java/com/sample/core/models/IncludeCollectionsModel.java


There are a few things to note here, as this is a Sling model you have access to the configured dialog properties via the ValueMapValue annotation. Via the Source annotation, you have access to a resource resolver which is managed by Sling.

Read Full Blog

AEM Content Services: Using Sling and Node APIs to Provide Asset collections - Part 1

Q&A

Please use this thread to ask the related questions.