Hi all,
How to customize segment using query string or cookie in Adobe CQ5.6?
My requirement as follows:
I wanted to target querystring parameters in Segment which is added in my Experience, Teaser, Promotion, Voucher for owned site.
Thanks in advance.
Regards,
Mayur
Solved! Go to Solution.
Views
Replies
Total Likes
Hi
Apart from what has Bsloki mentioned, we can create a OSGI which can basically read a query string and can create the content on the run time and then JSP can use that content to render it.
Link:- https://helpx.adobe.com/experience-manager/using/HttpClient_AEM.html (OSGI get request)
Link:- https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html (OSGI Post request)
Link:- http://stackoverflow.com/questions/13592236/parse-the-uri-string-into-name-value-collection-in-java (java code to read query string)
//
public static Map<String, String> splitQuery(URL url) throws UnsupportedEncodingException {Map<String, String> query_pairs = new LinkedHashMap<String, String>();String query = url.getQuery();String[] pairs = query.split("&");for (String pair : pairs) {int idx = pair.indexOf("=");query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));}return query_pairs;}
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
You can create the custom store/object like query parameters into client context and then use that attributes in your segmentation. refer [1] to see how to create custom client store
[1] http://blogs.adobe.com/aemtutorials/2013/07/24/customize-the-client-context/
Views
Replies
Total Likes
Hi
Apart from what has Bsloki mentioned, we can create a OSGI which can basically read a query string and can create the content on the run time and then JSP can use that content to render it.
Link:- https://helpx.adobe.com/experience-manager/using/HttpClient_AEM.html (OSGI get request)
Link:- https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html (OSGI Post request)
Link:- http://stackoverflow.com/questions/13592236/parse-the-uri-string-into-name-value-collection-in-java (java code to read query string)
//
public static Map<String, String> splitQuery(URL url) throws UnsupportedEncodingException {Map<String, String> query_pairs = new LinkedHashMap<String, String>();String query = url.getQuery();String[] pairs = query.split("&");for (String pair : pairs) {int idx = pair.indexOf("=");query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));}return query_pairs;}
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies