April 26, 2020
Estimated Post Reading Time ~

Fetch Content Fragment using AEM Core Components

Content Fragments can be rendered onto a page by below different ways:
  1. Using AEM core components
  2. Using Custom Sling Model
  3. Using Servlet to access Content Fragment.
Let's see how to render Content Fragment using AEM Core Components.

Enable AEM core components
Create a new project called “aemquickstart” using Adobe’s project archetype. Below is a maven archetype command to use. This will generate a boilerplate project with the latest version of Core Components.

mvn -B archetype:generate 
 -D archetypeGroupId=com.adobe.granite.archetypes 
 -D archetypeArtifactId=aem-project-archetype 
 -D archetypeVersion=23 
 -D aemVersion=cloud 
 -D appTitle="AEM Quickstart" 
 -D appId="aemquickstart" 
 -D groupId="com.aemquickstart" 
 -D frontendModule=general 
 -D includeExamples=n

Run below maven command to install the package in AEM
mvn clean install -PautoInstallPackage

Content fragment and content fragment list core components under ui.apps submodule
  • /project/ui.apps/src/main/content/jcr_root/apps/project/components/content/contentfragment
  • /project/ui.apps/src/main/content/jcr_root/apps/project/components/content/contentfragmentlist
Let's add these components on to the page.
  1. Go to AEM Start > Sites > aemquickstart > US > English
  2. Click on the parsys
  3. Click the plus icon
  4. Select Content Fragment
  5. Edit the content fragment
  6. Select the "AEM Book" content fragment that we created in the previous post
  7. Add Title, Description, Release Date and Image elements as shown below.
  8. Save the dialog


Now we can see the content fragment info on the page.


Let's add these components on to the page.

Go to AEM Start > Sites > aemquickstart > US > English
Click on the parsys
Click the plus icon
Select Content Fragment
Edit the content fragment
Select the "AEM Book" content fragment that we created in the previous post
Add Title, Description, Release Date and Image elements as shown below.
Save the dialog


Now we can see the content fragment info on the page.


Let's add these components on to the page.

Go to AEM Start > Sites > aemquickstart > US > English
Click on the parsys
Click the plus icon
Select Content Fragment
Edit the content fragment
Select the "AEM Book" content fragment that we created in the previous post
Add Title, Description, Release Date and Image elements as shown below.
Save the dialog


Now we can see the content fragment info on the page.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.