Expand my Community achievements bar.

Custom transformer for anchor links

Avatar

Level 1

Hi i have an issue when using a custom transformer extending from DefaultTransformer .
basically the requirements that i need are  :
being able to append text to all anchor links from a page this meaning is the anchor link its #clickme i should append to it baseUrl#clickme . I am using the AttributesImpl to handle the data and  i am able to process all the links that contain an anchor. Links containing anchor will be indicate by starting with # .
The problem is when updating the value , if i update the attribute using for example #clickme+baseurl and then call the supper.startElement it will generate the href tag correct  but the issue is that this is wrong. The correct order needs to be baseurl+#clickme the issue is that if i append anything before the #.   I try to append the full url , externalized url , vanity url , shorter url , random text before the #. It will not matter everything will break the html of the page to be specific the one that its containing the href but if i add anything after the # it will work.
i am getting crazy with this issue since for me it makes no sense any kind of help  or hints or insights will be greatly appreciated

adding extra info 
using the attributesImpl to set the attribute value ; 
#clickme/language/ch/consoles/offers this one will work
/language/ch/consoles/offers#clickme this one will break the page html that its an a tag containing a href  basically it will remove the a tag from the html

2 Replies

Avatar

Community Advisor

@armichedi so you are able to generate urls correctly as baseurl+#click me.. bit when you generate this your anchor tags are getting removed? Did you turn off your OOTB link checker? Please do.. of not it will validate link existence and remove hyperlink for invalid urls..

Avatar

Administrator

@armichedi Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni