Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Fetch data from CF and store in teaser

Avatar

Level 2

How I can fetch data that is stored in content fragment and show them in teaser?
For example in CF I have A,B,C,D fields and in teaser I just need A,B so teaser need to by dynamically populated based on CF?
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

Content fragment stored data in a node as properties. YOu can simply read those properties in Teaser component.

 

Example - https://github.com/arunpatidar02/aemaacs-aemlab/blob/master/ui.content/src/main/content/jcr_root/con... 

 

  1. Create a pathfield in the component dialog to browse CF.
  2. Parse the CF nodes and read A, B properties.

 

https://aemlab.blogspot.com/2018/09/aem-content-fragment-with-component.html

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi,

Content fragment stored data in a node as properties. YOu can simply read those properties in Teaser component.

 

Example - https://github.com/arunpatidar02/aemaacs-aemlab/blob/master/ui.content/src/main/content/jcr_root/con... 

 

  1. Create a pathfield in the component dialog to browse CF.
  2. Parse the CF nodes and read A, B properties.

 

https://aemlab.blogspot.com/2018/09/aem-content-fragment-with-component.html

Avatar

Level 8

@stefanjank  Steps:

1. Adapting a resource to Content Fragment.
2. Once we adapt to Content Fragment we get the object of CF which give the content fragment name i.e contentFragmentName.
3. Once we get the content fragment object, we can get all the properties associated with that content fragment (master node) by creating an iterator on CF object of type ContentElement.
4. We can iterate on the contentElement and get the property name in tagElement and it’s content in elementContent in above created variables.

 

The above code snippet provides details only related to the master of the content fragment. To get the details of the variations we can use the below API and the elements and other details:

Iterator<VariationDef> variationIterator = cf.listAllVariations();
while (variationIterator.hasNext()) {
String variationName = variationIterator.next().getName();
}

I suggest to refer below reference link to explore more API provided by Content Fragment Interface.

https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/reference-materials/javadoc/co...

 

Thanks