Expand my Community achievements bar.

SOLVED

Access request query string parameter in Sightly component

Avatar

Level 4

How do I access a request query string parameter in Sightly HTML. Do I have to expose it through the WCMUse model or can I just access it directly in the HTML?

1 Accepted Solution

Avatar

Correct answer by
Employee

You can use the following:

${request.requestParameterMap['test'][0].toString}

With http://server:port/resource?test=hello, then the output is ‘hello’

View solution in original post

8 Replies

Avatar

Level 10

See this Blog that talks about Sightly:

http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-4/

This talks about how to access the para­me­ters.

Avatar

Level 4

These are request attributes, not query string attributes e.g. getParameter. How do I get a query string parameter e.g. ?query=some+query

Avatar

Level 6

Once you have the SlingHttpRequest object you can get the parameters using request.getParameter method.

Have you tried that?

Avatar

Correct answer by
Employee

You can use the following:

${request.requestParameterMap['test'][0].toString}

With http://server:port/resource?test=hello, then the output is ‘hello’

Avatar

Employee

Please note that there is an issue with this since AEM6.3+SP1+CFP1 (AEM6.3.1.1)

Workaround here: htl-examples/request-parameter.html at master · heervisscher/htl-examples · GitHub

Avatar

Level 2

Try this:

${request.parameterMap.test}

Avatar

Level 2

Is it possible to return all the query string parameters? Similar to javascript window.location.search. Eg: current page url is https://google.com?utm_source=search&utm_media=online&param3=xxx and the expected return string is ?utm_source=search&utm_media=online&param3=xxx