Hi,
I have a call to action(cta) button component on a page, which has target URL pointing to parent. Now when I move that page to parent1, I want the target URL of cta should change and point to parent1.
How can I achieve that?
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @hptarora
You can try the below approach . Read the current page in the component.Then use the below method or any other method to get the parentpath.That can be assigned to the ctapath property and attached with the targetURL.
Resource res = resolver.getResource(currentPagePath);
Page page= res.adaptTo(Page.class);
String pageTitle = page.getPageTitle();
Page parentPage = page.getParent();
String ctapath= parentPage.getPath();
Hi @hptarora
You can try the below approach . Read the current page in the component.Then use the below method or any other method to get the parentpath.That can be assigned to the ctapath property and attached with the targetURL.
Resource res = resolver.getResource(currentPagePath);
Page page= res.adaptTo(Page.class);
String pageTitle = page.getPageTitle();
Page parentPage = page.getParent();
String ctapath= parentPage.getPath();
Hello @hptarora
In your case the reference isn't moved, thus AEM would not adjust it. The reference is present at the location and still valid.
Option-1: If this button always points to parent, you should use the approach suggested by @sherinregi . Easy on authors as well.
Option-2: use the listeners/workflows to adjust these links on Page move.
Option-3: Create your own "Action button in Sites UI" or "Workflow" for Moving such pages and adjust links.
Hello @aanchal-sikka ,
I think option 2 is better. Can you provide some more insight on this solution?
Is there a way I can overlay the file which actually does this move?
Thanks
Hello @hptarora
There is a thread about Page move events https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/resourcechangelistener-for...
Please check if it helps !
I would strongly opt for option 1.This is by far the easiest way, both in terms of coding and also in terms of runtime performance.
The downsides of option 2:
The downsides of option 3: