hi,
I have content fragment created. It has master, sub-variation-one, sub-variation-two.
Use case: change different fields in master variation, expecting changes to reflect in sub-variation.
Based on documentation : https://experienceleague.adobe.com/en/docs/experience-manager-65/content/assets/content-fragments/co...
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @sreenu539 , I think an Adobe support ticket will get help with this as an enhancement but for now maybe you can create an Event Listener to listen for changes to the content fragment resources and trigger the synchronization process. Something like below to check if this works as expected.
@Component(service = EventHandler.class,
immediate = true,
property = {
EventConstants.EVENT_TOPIC + "=" + PageEvent.EVENT_TOPIC,
EventConstants.EVENT_FILTER + "=(path=/content/dam/*)"
})
public class ContentFragmentEventListener implements EventHandler {
@Reference
private ResourceResolverFactory resolverFactory;
@Override
public void handleEvent(Event event) {
PageEvent pageEvent = (PageEvent) event;
for (ResourceChange change : pageEvent.getChanges()) {
try (ResourceResolver resolver = resolverFactory.getServiceResourceResolver(null)) {
Resource resource = resolver.getResource(change.getPath());
if (resource != null && isContentFragment(resource)) {
CustomContentFragmentModel model = resource.adaptTo(CustomContentFragmentModel.class);
model.synchronizeVariations(resource.getChild("jcr:content"));
}
} catch (LoginException e) {
// Handle exception
}
}
}
private boolean isContentFragment(Resource resource) {
return resource.getResourceType().equals("dam:Asset");
}
}
Hi @sreenu539 , I think an Adobe support ticket will get help with this as an enhancement but for now maybe you can create an Event Listener to listen for changes to the content fragment resources and trigger the synchronization process. Something like below to check if this works as expected.
@Component(service = EventHandler.class,
immediate = true,
property = {
EventConstants.EVENT_TOPIC + "=" + PageEvent.EVENT_TOPIC,
EventConstants.EVENT_FILTER + "=(path=/content/dam/*)"
})
public class ContentFragmentEventListener implements EventHandler {
@Reference
private ResourceResolverFactory resolverFactory;
@Override
public void handleEvent(Event event) {
PageEvent pageEvent = (PageEvent) event;
for (ResourceChange change : pageEvent.getChanges()) {
try (ResourceResolver resolver = resolverFactory.getServiceResourceResolver(null)) {
Resource resource = resolver.getResource(change.getPath());
if (resource != null && isContentFragment(resource)) {
CustomContentFragmentModel model = resource.adaptTo(CustomContentFragmentModel.class);
model.synchronizeVariations(resource.getChild("jcr:content"));
}
} catch (LoginException e) {
// Handle exception
}
}
}
private boolean isContentFragment(Resource resource) {
return resource.getResourceType().equals("dam:Asset");
}
}
@sreenu539 Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
Views
Likes
Replies