Expand my Community achievements bar.

MSM/Live Copy : Rewrite Reference Links Inside Experience Fragments or Template Structure Content | AEM Community Blog Seeding

Avatar

Administrator

BlogImage.jpg

MSM/Live Copy : Rewrite Reference Links Inside Experience Fragments or Template Structure Content by Sreenivas B

Abstract

The problem
Have you ever experienced this problem? Whenever you create a live copy/roll-out a master page, all the reference links inside a page get updated to the live copy equivalent links automatically; however, this is applicable only for the links which are stored inside a component property or page property in a page. If there are links referenced in editable template structure content or inside an experience fragment, which is used in a master page, it won’t be updated to the live copy equivalent link on roll-out. This is because these are shared or global content, which will be stored in one location (“/conf” or “/content/experience-fragments”).

The solution
Here is the solution: Use a custom “Link Transformer” to rewrite master links into live copy equivalent links.

The steps to implement a custom Link Transformer
Create a Transformer Factory

package com.aemks.core.transformers;

import org.apache.sling.rewriter.Transformer;
import org.apache.sling.rewriter.TransformerFactory;
import org.osgi.service.component.annotations.Component;

/**
* This link transformer factory is used to rewrite master links to live copy links
*/
@Component(
service = TransformerFactory.class,
property = {
"pipeline.type=referencelinkrewriter"
}
)
public class ReferenceLinkTransformerFactory implements TransformerFactory {

@Override public Transformer createTransformer() {

return new ReferenceLinkTransformer();
}
}

Read Full Blog

MSM/Live Copy : Rewrite Reference Links Inside Experience Fragments or Template Structure Content

Q&A

Please use this thread to ask the related questions.



Kautuk Sahni
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Reply

Avatar

Level 1

Can you please post the code inside ReferenceLinkTransformer.java class and also the config.xml content