Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

How can I create a groovy script to add pages under a node using same template?

zameer_abbas
Level 2
Level 2

Using one of my editable template, is there any way where I can create n-number of pages using any groovy script or any other script? 

AEM 6.5.5.0 content groovy page
1 Reply
Manjunath_K
Community Advisor
Community Advisor

Hi @zameer_abbas 

You can create pages under specific rootPath using editable templates by below mentioned groovy script.

 

def rootPagePath = "/content/we-retail/us/en/equipment/";
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);


for(int index=0; index < 5; index++){
pageManager.create(rootPagePath,"test"+index,"/conf/we-retail/settings/wcm/templates/content-page","Test Page Title"+index);
}

 

 

Groovy console successful execution of code :

groovy-console.png

 

 

Pages created after executing script :

pages.png

 

 

-Manjunath