Problem

Links within "IMG" and "FORM" tags are not rewritten (in contrast to links within "A" tags)

Resolution

In order to enhance the rewriting pipeline, you can do so by implementing a custom RewriterTransformerFactory [1]. This is an optional component used to extend the existing rewriting mechanism. Such a RewriterTransformerFactory must provide a Transformer [2] implementation through which the html to be rewritten passes as SAX events. In order to ease the implementation of custom rewriter transformers, an AbstractContentHandler [3] class is available for extension which provides default implementations of methods specified by the org.xml.sax.ContentHandler interface.

An example skeleton could look like this:

package x.y.z;
import com.day.cq.rewriter.pipeline.AbstractContentHandler;
import com.day.cq.rewriter.pipeline.RewriterTransformerFactory;
import com.day.cq.rewriter.pipeline.Transformer;
/*
*
* @scr.component metatype="no"
* @scr.service
* @scr.property name="service.ranking" value="-100" type="Integer"
*/
public class MyRewriterTransformer extends AbstractContentHandler
               implements RewriterTransformerFactory, Transformer {

  // override startElement method
  public void startElement(String uri, String loc, String raw, Attributes a)
               throws SAXException {

      // implement your custom link rewriting here
  }

  public Transformer createTransformer() {
      return new MyRewriterTransformer();
  }
}

Please note that the value of the service-ranking influences the order when this rewriting transformer will be triggered. See [1] for more details on that.

Applies To

CQ 5.2.x

[1] http://dev.day.com/content/docs/v5_2/cq-wcm-javadoc/index.html?com/day/cq/rewriter/pipeline/RewriterTransformerFactory.html


[2] http://dev.day.com/content/docs/v5_2/cq-wcm-javadoc/index.html?com/day/cq/rewriter/pipeline/Transformer.html


[3] http://dev.day.com/content/docs/v5_2/cq-wcm-javadoc/index.html?com/day/cq/rewriter/pipeline/AbstractContentHandler.html

이 작업에는 Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License의 라이센스가 부여되었습니다.  Twitter™ 및 Facebook 게시물은 Creative Commons 약관을 적용받지 않습니다.

법적 고지 사항   |   온라인 개인 정보 보호 정책