How to Perform a Global Find/Replace on the Text/HTML Module in DotNetNuke
If you need to replace content that is stored in the Text/HTML module in your DotNetNuke installation you could manually edit every text/html module, but you can also perform a global find/replace on all the content stored in that module through your database using the script below.
Before starting this process, you should make a complete backup of your website and database.
These steps require you to have Microsoft SQL Server Management Studio installed on your computer. To install MSSQL, please view the following article: How to Connect to MSSQL.
- Open Microsoft SQL Server Management Studio and connect to your database.
- Click on the New Query button.
- Copy and paste the following script into the New Query window replacing ORIGINAL with your original value and NEW with the new value, please see the note below for information on these values.
- Click Execute.
- Recycle your site's application pool following the instructions in our How to Recycle the Application Pool of a Website article.
When you are deciding what you want to find and replace, it is best to always be as exact as possible in order to avoid making unintended replacements. For example, let's say that you recently moved a DotNetNuke website from a virtual directory named /DotNetNuke into the root. You want to update all links so that they remove DotNetNuke. There are a couple different ways that you may be tempted to do this:
@Find = 'DotNetNuke'
@Replace = ''
The problem with this is that it will find all copies of the word 'DotNetNuke' and replace it with nothing. With this script, it will replace all instances of 'DotNetNuke', not just ones that are in URLs, so if you have content on your page about DotNetNuke, you'll lose this content.
@Find = '/DotNetNuke/'
@Replace = '/'
This script is better, however, it is not perfect. Most likely, anywhere that /DotNetNuke/ is listed, it will be part of a URL, however, it won't necessarily be completely accurate. For example, let's say that you have a URL such as /DotNetNuke/AreasOfExpertise/DotNetNuke/DotNetNukeProjects.aspx when the script above is run, the URL will be shortened to /AreasOfExperties/DotNetNukeProjects.aspx which is most likely not what you would have wanted.
@Find = '"/DotNetNuke/'
@Replace = '"/'
This script is much better because it has the " at the beginning. (This is the encoded version of the double-quote charater).