Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Experience Fragment export to target override link writing behaviour for usecase

Avatar

Level 5

Hi Team,

 

While exporting experience fragment to target , for element value like - 

<a href="tel:155555555"> is getting converted to <a href="https://<externalizer-domain>/#tel:155555555" 

 

and link behaviour after export stops working.

 

Believe this is happening w.r.t Experience Fragments Overview | Adobe Experience Manager

 

Want to know how we can handle the use case not to append domain when href has tel:.

 

Note - We have implemented 

ExperienceFragmentLinkRewriterProvider

but it is not getting called while we are exporting the experience fragment to target.

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

This will be invoked if the request uses the selector .atoffer, as explained in the blog. For example, if you have an Experience Fragment (XF) located at /content/experience-fragments/myXF/master.html, the rewrite will be triggered when you call upon /content/experience-fragments/myXF/master.atoffer.html. Make sure to register the selector as outlined in the blog.

 

For example:

EstebanBustamante_0-1728049022850.png

Hope this helps

 

 



Esteban Bustamante

View solution in original post

6 Replies

Avatar

Level 9

Add tel: to the Link Checker Special Link Prefixes http://localhost:4502/system/console/configMgr/com.day.cq.rewriter.linkchecker.impl.LinkCheckerImpl

or 

Add condition to overriden rewriteLink method to return link in case value starts with tel:

Avatar

Community Advisor

Hi @NehaCMS ,

We may put a condition if link doesn't start with tel: then only rewrite in rewriteLink method

Also check the priority if custom Rewriter doesn't get invoked

https://github.com/AdobeDocs/experience-manager-cloud-service.en/blob/main/help/implementing/develop...

https://exadel.com/news/aem-experience-fragments-url-externalization-with-adobe-target/

MukeshYadav__0-1727686199009.png

Thanks

Avatar

Community Advisor

Hi,

 

Please check out this blog: https://exadel.com/news/aem-experience-fragments-url-externalization-with-adobe-target/. It clearly explains what is happening and provides an example of how to address it. From the blog, you can see the code example. You should add a condition to the rewriteLink() method to check if the link starts with the "tel:" attribute. If this is not being called, check your rewrite configurations. As the blog explains, you should register a selector so that it is invoked when requested from outside of AEM.

 

Hope this helps!



Esteban Bustamante

Avatar

Level 5

hi @EstebanBustamante @MukeshYadav_ @Hemant_arora - 
We are overriding but the code is not getting called, we tried increasing the priority as well. Any pointer there

 

@Component(immediate = true, service = ExperienceFragmentLinkRewriterProvider.class)
public class TargetLinkRedirect implements ExperienceFragmentLinkRewriterProvider {

@Reference
ResourceResolverFactory resolverFactory;
@Reference
private Externalizer externalizer;
/**
* returns priority.
*/
@Override
public int getPriority() {
return 1;
}

/**
* returns Linkrewrite String.
*/
@Override
public String rewriteLink(String link, String tag, String attribute) {
// get the externalizer service
final ResourceResolver resolver = ServiceUtils.getServiceResourceResolver(resolverFactory);
externalizer = resolver.adaptTo(Externalizer.class);
if (externalizer == null) {
// if there was an error, then we do not modify the link
return null;
}
// remove leading /content/abc/en/ from resource link before externalizing
link = link.replace(Constants.CONTENT_HOME_PATH.getValue(), "");

// Externalising this URL to PROD
link = externalizer.externalLink(resolver, "abc", link);
return link;
}

/**
* return boolean.
*/
@Override
public boolean shouldRewrite(ExperienceFragmentVariation experienceFragment) {
return experienceFragment.getPath().contains("/content/experience-fragments");
}

}

Avatar

Correct answer by
Community Advisor

This will be invoked if the request uses the selector .atoffer, as explained in the blog. For example, if you have an Experience Fragment (XF) located at /content/experience-fragments/myXF/master.html, the rewrite will be triggered when you call upon /content/experience-fragments/myXF/master.atoffer.html. Make sure to register the selector as outlined in the blog.

 

For example:

EstebanBustamante_0-1728049022850.png

Hope this helps

 

 



Esteban Bustamante