Hi All,
We need to replace a specific text string, such as "Hello World," with "Greetings, Earthlings!" on approximately 2000 pages, text string is part of content fragment, What would be the best approach to accomplish this in AEM?
TIA..
Solved! Go to Solution.
Views
Replies
Total Likes
There are various ways to accomplish this. You can write a server or script to do this. You can also use groovy script as well as sling pipes. All the above will help you in automation
I suggest you write a custom servlet to find all content fragments under a specific path where it will find all instances of Hello World, replaces the word with Greetings, Earthlings!, and then it republishes all content fragments if they are already replicated; If content fragments are not yet activated, do nothing. Your servlet should also have a "mode=dry run" mode where it will just return you a list of all affected content fragments before the actually replace.
There are various ways to accomplish this. You can write a server or script to do this. You can also use groovy script as well as sling pipes. All the above will help you in automation
Is this not inefficient and a bit dangerous having everyone write a script / servlet that wants what is basic functionality?
I'd like to have search and replace across my library of content fragments but to write it myself seems a bit poor?
Views
Replies
Total Likes
Aem doesn’t provide you any ootb functionality that provides search and replace for the content. Atleast I am not aware of this. If you don’t want to write any type of automation then you can go with something called school way of creating a package of your content fragment and do a search and replace in the package directory after extraction using some ID and then making the package again and deploying it on aem. That’s the non-technical way I can think of without writing any automation (script/servlet)
Agreed @AEM_PARTY !
Content authoring Search and Replace just feels like something that should be available in a high-end, advanced tool like AEM without developers writing a script. A rudimentary version of it exists in the classic UI, but was never re-created in Standard (touch) UI.
Some use cases:
Maybe this is an opportunity for an AEM Commons tool?
It should:
Maybe someday!
Couldn't agree more and that is pretty much my use case. A product name changes and we have to manually go through hundreds of CFs updating them.
Views
Replies
Total Likes
Hi Team, please find below my blog post for Global find and replace text.
Views
Replies
Total Likes
Challenges that I see:
1. When we run the script to replace a text, the script also update the page that are in edit more and deploy the page without approval.
2. The text might be part of the url for example: /content/en_us/company/TextNeedToReplace/about-us
How to address these?
Views
Replies
Total Likes
Content in AEM is basically in 3 different publish statuses (maybe a few other subtle states):
The tool could simply ask which type to target for the change - only change if #3. Or maybe change all instances but only publish the changed content IF it is in one of those chosen by the user, otherwise don't publish. So, maybe only publish if the content is already published with no pending changes. Effectively a blend of the Classic UI "Find and Replace" and "Activate Tree".
As for AEM page paths, any change/rename/move of a page path obviously would need to ensure the process to change references also kicks off. This feels like something that should be out of scope.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies