Hi,
I am looking for a way to transform the current request URL into one with a different suffix and preserve everything else.
Does CQ (or Sling) has an API for doing this? Or do I have to do it manually, maybe with some help from slingRequest.getRequestPathInfo()?
Thanks,
Behrang
Solved! Go to Solution.
Views
Replies
Total Likes
You can get the suffix, selectors from the URL (https://sling.apache.org/apidocs/sling5/org/apache/sling/api/request/RequestPathInfo.html) but there is nothing to replace it. Hope you are already doing the same !
Views
Replies
Total Likes
I am not aware of any such methods in APIs. you should handle it manually.
but can you explain a usecase here ?
Views
Replies
Total Likes
We have a requirement to implement pagination and to use path variables rather than query parameters (e.g. /books/1, /books/2, etc. rather than /books?page=1, /books?page=2, etc.)
In this case, /1, /2, etc. are resolved as suffixes by CQ. So I need to extract the suffix and replace it. At the moment I am doing it manually, but it would be nice if there was a way to transform the current URL into another one with selector, suffix, etc. replaced with different values.
Views
Replies
Total Likes
You can get the suffix, selectors from the URL (https://sling.apache.org/apidocs/sling5/org/apache/sling/api/request/RequestPathInfo.html) but there is nothing to replace it. Hope you are already doing the same !
Views
Replies
Total Likes
Views
Likes
Replies