How to Use WCM Categories From Query Parameter for Personalization

Posted on Jul 13, 2017 (last modified May 7, 2021)

WebSphere Portal Logo Here’s how to use query parameters from the HTPP request (or from the URL) in a personalization component. This page came from my raw notes and hasn’t yet been rewritten for the broader audience; sorry. Posting it anyway for those who won’t mind a little sloppiness.

The personalization component must be rendered by the WCM servlet (the URL of which you can get from Previewing the component – DONT FORGET TO REMOVE NO CACHE PARAMS IN PROD). If you access it as rendered within the Web Content Viewer, the rule will not have access to the Request and won’t be able to get the request parameters.

Assuming the following taxonomy and categories…

And assuming the following content…

We’re going to create the following PZN rule…

We created 3 request parameters so that we can enforce a rule that insists that all 3 must be on the content (AND). With this, we can add the following to the URL:

&cat1=testcat1&cat2=testcat2&cat3=testcat3

We could alternatively have only 1 request param and do something like this:

&cats=testcat1,testcat2,testcat3

The problem with that is that it will only enforce an OR evaluation. If any content is tagged with any one of the given categories, it will show up.

Because we need to ensure that only content tagged with all 3 categories shows up, we create 3 separate request params. This allows us to use the PZN rule to enforce the AND condition.

Here’s how you make establish the request parameters and make them available in the pzn rule.

Step one: Click the value slot…

Step two: Navigate to Manage Properties… under the Request item…

When you’re just starting, you list may be empty (mine has some examples in it already).

Step Three: Click Add Dynamic Property…

Step four: Fill out as follows…for example…

Click SAVE.

Click DONE.

Your new item should show in the list under Request…

Preview the PZN Component. Remove the unecessary params (like no chache) from the URL for PROD. Add your parameters and category names to the URL. For example:

http://local.base22.com:10039/wps/wcm/myconnect/web%20content/articles?source=library&srv=cmpnt&cmpntid=0d99a109-b8c7-4f38-a9ae-8d48faf37e32&cat1=testcat1&cat2=testcat2&cat3=testcat3

And you get: