What are the recommendations/best practices for conditionally modifying links of actions from the Teaser component based on various business rules.
Environment:
- AEM 6.5.8
- Core Components 2.14.0
Use Case:
Authors add the Teaser component to a page. While doing so, they enable and add actions to the Teaser component.
When the page is rendered, we would like to add a query string to the URL associated with the action based on conditions defined by business rules. So, for certain links, we would like them to appear as https://ourcompany.com/products/ourproduct1.html?param1=1234¶m2=abcd, but, for others it would simply appear as https://ourcompany.com/products/ourproduct2.html.
We have tried both front-end and backend solutions.
On the front-end, we have tried to overlay the action.html file to pass the ${action.URL} parameter to javascript in order to take the original value entered by the author and modify it per requirements. However, it seems as we are unable to pass that value into javascript as they are coming across as undefined.
In the back-end, we have tried to access the actions, but, Teaser actions are of type List<ListItem> which is an unmodifiable collection. As a result, we are not able to modify action elements.
Question:
Is there a best practice or preferred manner in which we can accomplish the above?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
You can extend the teaser and modify the links
https://github.com/arunpatidar02/aem63app-repo/blob/master/java/CustomTeaser.java
1. get a link from teaser.getActions(); inside init and create a new list out of it
2. return new list
@Override public List<ListItem> getActions() { return newActionList; }
Hi,
You can extend the teaser and modify the links
https://github.com/arunpatidar02/aem63app-repo/blob/master/java/CustomTeaser.java
1. get a link from teaser.getActions(); inside init and create a new list out of it
2. return new list
@Override public List<ListItem> getActions() { return newActionList; }