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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to add property and author a component for 2000 pages (same template) programmatically

Avatar

Level 2

I am using AEM 6.5.9. I have a requirement to redesign 2000 pages of the website which are using the same template.

 

As part of website redesign I need to 

1) add a property to the JCR for say 600 pages of the 2000

2) add a component to 2000 pages and display the output for the page

 

Please let me know the best approach for this using AEM programming. Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 2
6 Replies

Avatar

Correct answer by
Level 2

Create an on deploy script and use ACS On-Deploy pattern On-Deploy Scripts (adobe-consulting-services.github.io)

 

I've put sample code and examples here How to add property and author a component programmatically? - AEM.Design

Avatar

Level 2

Thanks for the reply @maxbarrass-anchora.

 

This approach looks good to add/modify properties. How do I author a component in 2000 pages, please suggest.

 

Thanks.

Avatar

Level 3

Hi @Lalitha_j 

There are many ways of doing this, if acs-tools package is installed in your AEM instance then this can be achieved through AEM Fiddle console. And adding a new component to the page can be achieved through ResourceResolver API. Write the business logic in Fiddle console and run your code.

Avatar

Level 2

You can write a function that accepts a  resource and makes necessary structure under it. Do you want an example?

 

Side note. Also as this is On-Deploy code you can find examples of unit tests in the ACS repo. Other methods you will be shooting blind.

Avatar

Community Advisor

This can be done through Groovy Script

- Installation:

https://github.com/icfnext/aem-groovy-console

 

- Help Docs:

https://hashimkhan.in/aem-adobecq5-code-templates/groovy-script/

https://labs.tadigital.com/index.php/2018/12/18/groovy-script-in-aem/

 

 

It is similar to Java, and you can write a script and run through your groovy console on every environment.