Hi all again, well here's an example - note I've modified a sample I found on the web - it uses the ability to search recursively in text data type fields. You simply need to determine in which tables and which fields you need to search, and adjust search string patterns. For example I inject javascript inside HTML/Text module instances under settings | configuration --> Header, and thus the table to look for is HtmlText (column Header). I think this script could well serve to the community and hence would strongly suggest the DNN Core Team to pick up this topic to make DNN installations more portable more easily. I myself now have pretty good control over what I'm doing and now manage two sets of about 7-10 different scripts, each one to set or reset image paths. It really gives me the possibility to develop local and update on my remote (much slower) host.
The example script is:
==============================
/* 01 - script for replacing one specific imagepath in a DNN 4.5.x DB */
/* table HtmlText */
/* author: Pieter Siegers with help from a script I found on Internet */
/* look for pattern in dbo.HtmlText - h.DesktopHtml */
SET NOCOUNT ON;
DECLARE
@TextPointer BINARY(16),
@TextIndex INT,
@oldString NVARCHAR(100),
@newString NVARCHAR(100),
@lenOldString INT,
@currentDataID INT;
SET @oldString = N'src="/Portals/0/Migesa/';
SET @newString = N'src="/DNN453Site01/Portals/3/Migesa/';
IF CHARINDEX(@oldString, @newString) > 0
BEGIN
PRINT 'Quitting to avoid infinite loop.';
END
ELSE
BEGIN
SELECT 'Before replacement:';
SELECT ModuleID, DesktopHtml FROM HtmlText
WHERE PATINDEX('%'+@oldString+'%', DesktopHtml) > 0;
SET @lenOldString = DATALENGTH(@oldString)/2;
DECLARE irows CURSOR
LOCAL FORWARD_ONLY STATIC READ_ONLY FOR
SELECT
ModuleID
FROM
dbo.HtmlText
WHERE
PATINDEX('%'+@oldString+'%', DesktopHtml) > 0;
OPEN irows;
FETCH NEXT FROM irows INTO @currentDataID;
WHILE (@@FETCH_STATUS = 0)
BEGIN
SELECT
@TextPointer = TEXTPTR(DesktopHtml),
@TextIndex = PATINDEX('%'+@oldString+'%', DesktopHtml)
FROM
dbo.HtmlText
WHERE
ModuleID = @currentDataID;
WHILE
(
SELECT
PATINDEX('%'+@oldString+'%', DesktopHtml)
FROM
dbo.HtmlText
WHERE
ModuleID = @currentDataID
) > 0
BEGIN
SELECT
@TextIndex = PATINDEX('%'+@oldString+'%', DesktopHtml)-1
FROM
dbo.HtmlText
WHERE
ModuleID = @currentDataID;
UPDATETEXT dbo.HtmlText.DesktopHtml @TextPointer @TextIndex @lenOldString @newString;
END
FETCH NEXT FROM irows INTO @currentDataID;
END
CLOSE irows;
DEALLOCATE irows;
SELECT 'After replacement:';
SELECT ModuleID, DesktopHtml FROM HtmlText
WHERE PATINDEX('%'+@newString+'%', DesktopHtml) > 0;
END
==========================
Then, to return those paths, I simply switch the search patterns (note the rest of the script stays the same):
/* returning paths */
SET @oldString = N'src="/DNN453Site01/Portals/3/Migesa/';
SET @newString = N'src="/Portals/0/Migesa/';
HTH, Pieter