I have used Content Reference in a content fragment. Basically, my need is to redirect the content fragment to the link inserted in the content reference field whenever it is clicked. But the problem is the redirection is done to the exact link which I insert in the field. For eg: if I save link as, /conten/wknd/en/..., the redirection link will be same. But I want that when the redirection is done, the /content/wknd/en/ should be removed from the link. I did it with js and it's working fine. But I want to try any other method like using link transformer. Is there any other way to do this?
Solved! Go to Solution.
Views
Replies
Total Likes
Is your link appearing on a sites page (component is rendering the content on html page)? If so, the link transformer should modify the link if that is handled in the code. Transformer code should read the correct tag in order to modify the link. Also, if the links are on page, you can use sling mappings too.
Hi @nikita24tailor ,
There are two ways you do a URL shortening in AEM:
1. Sling Mappings - https://blog.3sharecorp.com/shortening-urls-in-aem
2. Using Sling Transformers in AEM - https://wttech.blog/blog/2019/how-to-use-sling-transformers-in-aem/
Depending on your implementation, you can chose either of the two solutions. Sling Mapping is an OOTB implementation where you can transform your URL with some configuration. This is straight forward. If you use Sling Transformers, you have to write a class, and you can manipulate the URL in any tag. Please go through both the links I shared. Let me know if this satisfies your requirement.
Link transformation is already done for the project but that is not working in this case of content fragment.
Is your link appearing on a sites page (component is rendering the content on html page)? If so, the link transformer should modify the link if that is handled in the code. Transformer code should read the correct tag in order to modify the link. Also, if the links are on page, you can use sling mappings too.
Yes, the links are appearing on the site's page but they are not transformed. Whereas the link transformer is working fine for other components.
Can you share the snippet from you page source, how it is rendering on the page.
Thanks, the problem is solved.
Hi @nikita24tailor - Is the content fragments parent path added to the paths[] property of the rewriter configuration?
Thanks, the problem has been solved.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies