Create date field in content fragment programatically
How to add date field in the content fragment which is created programatically
How to add date field in the content fragment which is created programatically
@helptech You can follow the below for creation of CFs programmatically.
Resource fragmentResource = resourceResolver.getResource(fragmentPath);
if (null != fragmentResource) {
ContentFragment contentFragment = fragmentResource.adaptTo(ContentFragment.class);
if (null != contentFragment) {
Iterator<ContentElement> elements = contentFragment.getElements();
while (elements.hasNext()) {
ContentElement contentElement = elements.next();
if (contentElement.getValue().getDataType().isMultiValue()) {
String[] values = contentElement.getValue().getValue(String[].class);
String value = null;
if (values != null) {
value = StringUtils.join(values, CommonConstants.CHAR_COMMA);
cfElements.put(contentElement.getName(), value);
}
} else {
cfElements.put(contentElement.getName(), contentElement.getContent());
}
}
}
}
Some other helpful links :
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.