Expand my Community achievements bar.

SOLVED

Content Placeholders / Replace Text on Page with Query String Parameters?

Avatar

Level 4

We're looking to set up a system that replaces placeholder text on a page based on passed query string parameters. For example, the authored content would look like -

The customer, {CUSTOMER_NAME} can be sold the product for {PRODUCT_PRICE}.

And those placeholder values could be swapped out in the jsp through the url query string parameters -

/content/site/page1?customer_name=Smith&product_price=6.99

I'm sure we could develop this ourselves fairly easily but i was wondering if there was anything out of the box that supported any kind of content placeholder/text replacement?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi,

In AEM/CQ, personalization (whether by geolocation or referrer or anything else) is meant to be done on the client side. It sounds like your whole system needs to be reconsidered.

That said, to answer your specific question, the closest thing included in the product would be http://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/text/StrSubst...

Regards,

Justin

View solution in original post

6 Replies

Avatar

Level 2

Before I answer this, I would like to know why you want to do something like this. I would highly discourage to use query string parameters since it breaks CQ dispatcher caching strategy completely. On the other hand, generally data is kept in JCR which you can display on JSP to bring in dynamism, I see no use case of end users passing all these parameters since you will have no limitations.

So before I answer can you let me know what is the use case you are trying to achieve?

Avatar

Correct answer by
Employee

Hi,

In AEM/CQ, personalization (whether by geolocation or referrer or anything else) is meant to be done on the client side. It sounds like your whole system needs to be reconsidered.

That said, to answer your specific question, the closest thing included in the product would be http://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/text/StrSubst...

Regards,

Justin

Avatar

Level 4

Reposting this because it somehow got deleted:

I understand your skepticism, so i'll explain a bit more. Firstly, to your point about the dispatcher's cache -  sad to say we've disabled the cache completely. All of our pages have to be dynamically created depending on the user (eg. a page will display differing content depending on what part of the country the user is in).

The use case for the replaceable parameters goes something like this:

  1. Calling system (Not CQ) displays the customer's information (name, price offered, etc.) to the user and a link to the CQ content.
  2. User clicks the link to open the CQ content page and promptly forgets the customers name/price offered.
  3. The calling system passed the customer's name and price to be offered in the query string so CQ grabs those and integrates them into the content page where appropriate. Now the user doesn't need to go back and forth between the two pages.

Avatar

Level 4

Thanks Justin, i'll take a look at that. It's a bit more complicated than what i described, unfortunately. The personalization is based on two factors - location of the user and what role they are. The content that we filter out is information that they are not legally allowed to see. So we have to do it on the server side in the event that some user looks at the source and sees something they're not supposed to.

Avatar

Employee

Hi,
Yes, I agree that security and personalization are different and that security must be handled on the server side. That said, passing the price via a query parameter is not really secure smiley so I'm sure you can understand the confusion.

Justin

Avatar

Level 4

Ha absolutely, price was probably a bad example. It's more contextual information than anything that would be a security issue.

Appreciate the help!