How to update content while moving page in AEM | Community
Skip to main content
Level 3
October 13, 2023
Solved

How to update content while moving page in AEM

  • October 13, 2023
  • 2 replies
  • 1247 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by sherinregi-1

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();

 

2 replies

sherinregi-1
Community Advisor
sherinregi-1Community AdvisorAccepted solution
Community Advisor
October 13, 2023

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();

 

aanchal-sikka
Community Advisor
Community Advisor
October 13, 2023

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-1 . 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.

 

Aanchal Sikka
hptaroraAuthor
Level 3
October 13, 2023

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

aanchal-sikka
Community Advisor
Community Advisor
October 13, 2023