Expand my Community achievements bar.

SOLVED

Timewarp Functionality CQ

Avatar

Level 1

Hi,

I have created a component which uses some content from different page. As reference paragraph stores the absolute path of the referenced content, my component stores relative path. For example if reference component stores “/content/mysite/en_uk/home/jcr:content/par/hero/linktext”  then my component will store path “par/hero/linktext”.The reason for this is we have multiple sites and for each of them this page path can be different. So I have created full URL in the backend by using SlingRequest and determining its parent by using absoluteParent method.  But when I am using timewarp functionality the path returned is /jcr:System/42/56/34/5....." instead of "/content/mysite...", which is expected, but this breaks ,my logic. Is there an OOTB way to get the natural path starting with /content/mysite instead? 

Thanks

Mayank

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi mayank,

if your requirement is to only prepare the absolute path to the current resource, in this case "par/hero/linktext" then you can use other approach to. For example get the current page content resource path and then append the remaining path you already have as below

String jcrContentResourcePath=pageManager.getContainingPage(currentNode.getPath()).getContentResource().getPath();  //this will give you path till jcr:content of current page for example "/content/mysite/en_uk/home/jcr:content"

then just append what you have from component property "par/hero/linktext"

String absolutePath=jcrContentResourcePath+"/"+"par/hero/linktext";

I hope it will help you to resolve your issue. There are various way to achieve this using APIs

 

Thanks,

Pawan

View solution in original post

3 Replies

Avatar

Level 9

Hi mayank,

Can you plz elaborate more... the usage timewrap functionality to retrieve the path? 

Thanks,

Pawan

Avatar

Level 1

Hi Pawan,

I am using getAbsoluteParent() method using the sling request. But in timewarp request is keep on changing for every different version and if I see the path info of slingRequest it starts with "/jcr:system... " instead of "/content/geometrix...". This is causing problem when I am creating full URL in back end using absoluteParent method then appending some string to it.

Thanks

Mayank
 

Avatar

Correct answer by
Level 9

Hi mayank,

if your requirement is to only prepare the absolute path to the current resource, in this case "par/hero/linktext" then you can use other approach to. For example get the current page content resource path and then append the remaining path you already have as below

String jcrContentResourcePath=pageManager.getContainingPage(currentNode.getPath()).getContentResource().getPath();  //this will give you path till jcr:content of current page for example "/content/mysite/en_uk/home/jcr:content"

then just append what you have from component property "par/hero/linktext"

String absolutePath=jcrContentResourcePath+"/"+"par/hero/linktext";

I hope it will help you to resolve your issue. There are various way to achieve this using APIs

 

Thanks,

Pawan