Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Component Content Replication

Avatar

Level 2

Hi All,

I have a component authored in like more than 100 of pages. Now I wanted to make changes to the content of that component. Is there any way in AEM so that the changes should be reflected to the component on all the pages? or any workaround for it?

Any help will be highly appreciated.

Thanks,

Hafeez

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

HI,

that's not a common requirement. In that case you should have payed more attention to your content structure; reuse can be achieved much easier than copying content from one page to another. Maybe using an iparsys, a reference component, MSM, content fragments/experience fragments?

If you really want to copy the component from one page to others, locate the component in that page, and copy it to the other locations. Use CRXDE Lite for this. Still, I don't think that this is a good idea, and that this process is sustainable over the long term, especially if it ocurs more than once.

Jörg

View solution in original post

8 Replies

Avatar

Level 4

You should create a rollout task (script or java classes) to fix(otherwise your existing content will be broken) all changes according to certain criteria (for example all content under this path-/content/myapp/myfolder/- must add this new property -newProperty=false- to ensure all pages render property).

To select which pages should be updated, you could do it thru query by resourceType="yourComponent" &  id="/content/myapp/myfolder/". This rollout will be run only one time.

Regards

Diego

Avatar

Administrator

Which version of AEM are you on?

If you are on AEM 6.2 or more, I would use content fragment for this.

Or Experience fragment, if your need to have a common experience of few set of components across these pages/site.

+1 with solution mentioned by MC Stuff

and also have look at bulk editor:- How do I update content in multiple pages?

~kautuk



Kautuk Sahni

Avatar

Community Advisor

You can also use bulkeditor for this.. Write a query to find all the instances of the component, download as excel, edit and upload excel..

Avatar

Level 10

How is the component created - if its defined in 1 place - ie - /apps/<YOUR PROJECT>/components<Your Component> - when you make a change to that component - you should see the changes reflected in all instances. - this is for the functionality of the component.

If you are talking about the data within a component -- ie the Text component -- and you want to change the data  - other ppl have mentioned some good ways to do so.

Avatar

Level 2

I am able to find the content but am unable to replace it? I wanted to copy the content from one of the page which holds the component to all the other pages which has the same component on them.

Avatar

Correct answer by
Employee Advisor

HI,

that's not a common requirement. In that case you should have payed more attention to your content structure; reuse can be achieved much easier than copying content from one page to another. Maybe using an iparsys, a reference component, MSM, content fragments/experience fragments?

If you really want to copy the component from one page to others, locate the component in that page, and copy it to the other locations. Use CRXDE Lite for this. Still, I don't think that this is a good idea, and that this process is sustainable over the long term, especially if it ocurs more than once.

Jörg

Avatar

Community Advisor

    - When you say content of the component, do you mean the entire content or a particular property ? If entire content , then as Jörg Hoh​ suggested , there is a serious flaw in your design . But since its all done and you are looking for a solution , If all the above solutions are not working, Can you try doing something like below

  1. Create a servlet , in that fetch the component you have the correct content , retrieve the content in an object.
  2. Once you have the content., write a query and fetch all the nodes of the components where you want to paste this content .
  3. Once you have the result set, in a loop , replace the property content , with the one you already retrieved in step 1

Few points to remember

  • This is completely a work around , and cannot be considered as a recommended solution.
  • Do not run this code on your server unless tested properly in your local machines
  • If the code works as expected, install the same in your DEV server , rewrite the content and package and install it in other servers . Never, run such scripts in your STAGE or PROD servers.

Thanks

Veena