I think the below design should help you
You need to rewrite all href link on the page by appending wcmmode=disabled,
- Create a Transformation class and extend it from the org.apache.cocoon.xml.sax.AbstractSAXPipe
- In the startlement iterate all attributes of element
- Find href link
- Check if it contains query string with wcmmode=disabled
- if so then rewrite url
- finally assign back to href
Check below sample code :
public void startElement(String uri, String loc, String raw, Attributes attributes) throws SAXException {
AttributesImpl attrs = new AttributesImpl(attributes);
for (int i = 0; i < attrs.getLength(); i++) {
String name = attrs.getLocalName(i);
if(name.equals("href"))
{
String url = attrs.getValue(i);
// write an if condition to check url endwith wcmmode or not
/ if so then rewrite th url something like below
url = "http://keysandstrokes.info?wcmmode=disabled";
//finally set value back to the href attribute
attrs.setValue(i, url);
}
}
super.startElement(uri, loc, raw, attrs);
}
Example: you can use it as it is by applying your logic in the start element
http://keysandstrokes.info/apache-sling-rewriter-how-to-rewrite-urls-in-aemcq5/
Approach 2:
You can also do this using Jquery, but you must have knowledge of it. Using Jquery find out all href links and rewrite it, this is simple than approach 1 and it will not put any burden on the server as it is authoring environment so we can consider this. the Jquery should load at end of the page once the entire DOM is loaded.
You need to load Jquery only in author mode don't execute on publish mode.
Approach 3 :
Check is there any OOTB functionality available or not, if not then try above approaches.