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?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Content fragment stored data in a node as properties. YOu can simply read those properties in Teaser component.
https://aemlab.blogspot.com/2018/09/aem-content-fragment-with-component.html
Hi,
Content fragment stored data in a node as properties. YOu can simply read those properties in Teaser component.
https://aemlab.blogspot.com/2018/09/aem-content-fragment-with-component.html
@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.
Thanks
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies