I want to fetch the data from the different variation of content fragment in my java class. I am using Content Fragment API.
Solved! Go to Solution.
Views
Replies
Total Likes
Also noticed while looping thru contentElement
Iterator<ContentElement> contentElement = cf.getElements();
while(contentElement.hasNext()){
ContentElement contentElementObject = contentElement.next();
ContentVariation cv = contentElementObject.getVariation(variationName); // get variation names early
String contentText = cv.getContent(); // This gives variation's content for that element
}
To list all variations of a CF
Iterator<VariationDef> variationIterator = cf.listAllVariations(); -
Iterate the contents inside CF.
Iterator<ContentElement> contentElement = cf.getElements();
ContentElement contentElementObject = contentElement.next();
String tagElement = contentElementObject.getName().toString();}
I need variation content and not just the list of variation. Iterator<VariationDef> variationIterator = cf.listAllVariations(); this is not helping as the iterator is of type variationDef.
Your second code snippet also won't help because the content element is of master and i need elements of other variations
Views
Replies
Total Likes
@Shaheena_Sheikh One suggestion could be use get the name using VariationDef and make a call to Graph QL and get the elements since VariationDef API gives very basic metadata not the elements.
Example below to get the elements of variation using Graph QL
Also noticed while looping thru contentElement
Iterator<ContentElement> contentElement = cf.getElements();
while(contentElement.hasNext()){
ContentElement contentElementObject = contentElement.next();
ContentVariation cv = contentElementObject.getVariation(variationName); // get variation names early
String contentText = cv.getContent(); // This gives variation's content for that element
}