R2i DotNetNuke® Forum

R2i wants you to have the opportunity to ask questions, post reviews, help others or just rant and rave about DotNetNuke® or any of the R2i Modules and Skins. Our team spends hour upon hour, day after day, working on custom DotNetNuke® modules and services; please feel free to ask us anything.
 
Find and Replace Procedure for Html Module
Last Post 10 Mar 2010 04:18 PM by sypa. 27 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Page 2 of 2 << < 12
Author Messages Informative
stefanpUser is Offline
New Member
New Member
Posts:2

--
06 Sep 2007 01:33 PM  
Thanks, that worked great.

I now notice that the are other modules like Announcements (News) and Links that have broken image links.

I tried modifying the code for the Replace_DestopHTML proc to do a search and replace in the Announcements table but it looks like this table can return multiple ModuleIds for a single announcement so the procedure doesn't work and I'm not savvy enough in SQL Server stored proc development to make the code change.

Anyway, I used the follwing code which searches all DNN tables to find potentiallly problematic image links:

CREATE PROC SearchAllTables
(
@SearchStr nvarchar(100)
)
AS
BEGIN

-- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved.
-- Purpose: To search all columns of all tables for a given search string
-- Written by: Narayana Vyas Kondreddi
-- Site: http://vyaskn.tripod.com
-- Tested on: SQL Server 7.0 and SQL Server 2000
-- Date modified: 28th July 2002 22:50 GMT
-- Searches only the following data types: 'char', 'varchar', 'nchar', 'nvarchar' (not 'ntext')

-- usage EXEC SearchAllTables 'Computer'
-- GO



CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))

SET NOCOUNT ON

DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
SET @TableName = ''
SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')

WHILE @TableName IS NOT NULL
BEGIN
SET @ColumnName = ''
SET @TableName =
(
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
AND OBJECTPROPERTY(
OBJECT_ID(
QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
), 'IsMSShipped'
) = 0
)

WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
BEGIN
SET @ColumnName =
(
SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2)
AND TABLE_NAME = PARSENAME(@TableName, 1)
AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
AND QUOTENAME(COLUMN_NAME) > @ColumnName
)

IF @ColumnName IS NOT NULL
BEGIN
INSERT INTO #Results
EXEC
(
'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
FROM ' + @TableName + ' (NOLOCK) ' +
' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
)
END
END
END

SELECT ColumnName, ColumnValue FROM #Results
END
ramiUser is Offline
New Member
New Member
Posts:1

--
24 Jul 2008 06:52 AM  
hi ,

mmm ok if i have more than one url in the same row ?
this prosuder checking if it's have one or more than one url to replace it ?

thank you
really well do <img src='desktopmodules/ntforums/images/emoticons/wow.gif' height='20' width='20' border='0' title='Wow' align='absmiddle'>
robert_chumleyUser is Offline
Advanced Member
Advanced Member
Posts:592

--
06 Aug 2008 04:12 PM  
You may need to experiment with this solution to determine if it is getting everything and solving all the broken link problems. It appears this script will work in that scenario to replace multiple occurrences. We strongly urge you to do a full set of tests on the process before committing the final batch. As with all Find and Replace algorithms, it could lend itself to unexpected results fairly easily.
Thanks,
Robert Chumley<br>r2integrated (formally bi4ce)
nonstopmarkUser is Offline
New Member
New Member
Posts:1

--
23 Sep 2008 04:46 PM  
I have just applied the create procedure above and applied it to a locally hosted website (previously hosted) and all images are displayed. Excellent.

Am I right in thinking that if I re-deploy the website to a hosted account with a domain name, I re-apply the procedure below...

Replace_DesktopHtml '/Portals/0/','';

But in reverse, e.g.

Replace_DesktopHtml '','/Portals/0/';

Thanks in advance for all you help here...

Cheers

MARK.
www.markwhitfield.net
bgatesUser is Offline
Basic Member
Basic Member
Posts:196

--
05 Oct 2008 05:14 PM  
BAD IDEA! I fear that would actually replace all content with just '/Portals/0/'. If you're replacing images, you may want a more directed replacement like:

Replace_DesktopHtml 'src="http://www.r2idnn.com/images"', 'src="http://www.r2idnn.com/Portals/0/images"'
Bob Gates<br>Business Intelligence Force, Inc. (<a href="http://dnn.bi4ce.com"><b>bi4ce</b></a>)
tkraakUser is Offline
New Member
New Member
Posts:1

--
06 May 2009 01:44 AM  
Has anybody mentioned these e modules?

http://seablick.com/blog/84/find-and-replace-text-across-dnn-modules.aspx


http://www.engagesoftware.com/Products/Modules/Engage_F3.aspx
dbs98765User is Offline
New Member
New Member
Posts:1

--
07 Sep 2009 09:20 PM  
I cannot get this to work with DNN V4.9.4, although it worked fine with v4.9.2. Any ideas?
sypaUser is Offline
New Member
New Member
Posts:1

--
10 Mar 2010 04:18 PM  
Hi,
I tried the above but get lots of errors - saying

Error 170: Line 1: Incorrect syntax near...'/development'.
Must declare the variable '@For'.
Must declare the variable '@With'.
Must declare the variable '@For'.
Must declare the variable '@For'.

I have only changed this bit:
CREATE Procedure Replace_DesktopHtml '/development', ''

As i want to remove '/development' from my site.

Thanks.
mark.
You are not authorized to post a reply.
Page 2 of 2 << < 12


Active Forums 4.1
 

New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seatle, WA • 410.327.0007 • info@R2Integrated.com

Bookmark & Share Bookmark and Share