You need to Register for free and Login to post a message in the forum.

Forum

Subject: Issue 22 Replace_DesktopHTML
Prev Next
You are not authorized to post a reply.

Author Messages
DavidWSnow
DNN Creative Magazine Subscriber
Nuke Master
Nuke Master
Posts:124

05 Sep 2007 11:27 AM  

I tried and tried the procedure with no success. I usually move my database the other direction that you did in your example. I develop content online in hidden pages, and then make them public.

I clone my production database to localhost while developing new skins or ListX applications then install them on the production server.

You can't use this procedure in a single step to go from production to localhost!

Images in my production database begin with '/Portals/0/' while on my localhost they have '/asi3/Portals/0/'

You can't just do Replace_DestopHTML '/Portals/0/', '/asi3/Portals/0/'

because the procedure just loops on the same entry endlessly replacing the /Portals/0/

I found that I had to do Replace_DestopHTML '/Portals/0/', '/asi3/Portals/a/'
followed by
Replace_DestopHTML '/Portals/a/', '/Portals/0/'

I suppose that the next time i'll actually tweak this an miss-spell Portals rather than using the portal number, so that I don't have to do it one time per portal.


leesykes
DNN Creative Staff
Nuke Master III
Nuke Master III
Posts:3351

06 Sep 2007 10:33 AM  
Hello,

Thanks for the info, that's useful to know,

Cheers,

Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/leesykes

Lee Sykes's Facebook Profile
julianhorn
Nuke Newbie
Nuke Newbie
Posts:4

26 Sep 2007 10:06 AM  

Hi,

I might be teaching my grandmothers to suck eggs here  but I couldn't get the procedure to run properly - it just kept coming back with "There is an error in your query".

Googling around, I realised that - fairly obviously - if you have put an object qualifier on the database (as I had) when setting up your site, then you need to modify the code in 4 places (Assuming you want the procedure to reside in "your" part of the database) to add that qualifier as below.

After making these changes it seems to work OK - am I right here or am I making some big mistake through my ignorance??

CREATE Procedure YOURQUALIFIER_Replace_DesktopHtml(
    @For as varchar(100),
    @With as varchar(100))
AS
--* REPLACES TEXT IN THE DESKTOP HTML MATCHING THE FOR VARIABLE
--* SAMPLE: Replace_DesktopHtml '/Portals/0/', ''

--* MAIN DECLARATION
DECLARE
    @pointer binary(16),
    @index INT,
    @lenFor INT,
    @lenWith INT,
    @diff int,
    @id INT,
    @count INT

--* STANDARD RUNTIME VARIABLES
SET @lenFor = LEN(@For)
SET @diff = @lenFor - LEN(@With)

--* CREATE THE TEMPORARY TABLE
CREATE TABLE #Temporary
    (
        [id] int,     --MAPS TO YOUR SOURCE TABLE PKID
        [oldtext] text, --ORIGINAL SOURCE TEXT (NOT REQUIRED)
        [oldlength] int,--ORIGINAL SOURCE LENGTH
        [text] text,     --NEW TEXT VALUE
        [length] int,     --NEW LENGTH
        [cLength] int    --CHECKSUM LENGTH
    )

--* LOOP THROUGH THE SOURCE TABLE
--* IDENTIFY ALL RECORDS WHICH MATCH YOUR PATTERN
DECLARE irows CURSOR
    LOCAL FORWARD_ONLY STATIC READ_ONLY FOR
    SELECT moduleid
        FROM YOURQUALIFIER_HtmlText
        WHERE PATINDEX('%'+@For+'%', DesktopHtml)>0
OPEN irows

FETCH NEXT FROM irows INTO @id

WHILE (@@FETCH_STATUS = 0)
BEGIN
--* INSERT MATCHING RECORDS INTO THE TEMPORARY TABLE
    INSERT INTO #Temporary(id, oldtext, oldlength, text)
    SELECT
        ModuleID,
        DesktopHtml,
        datalength(DesktopHtml),
        DesktopHtml from YOURQUALIFIER_HtmlText
    where ModuleID = @id

--* GRAB THE POINTER OF THE OBJECT TO BE USED FOR UPDATETEXT
    SELECT
        @pointer = TEXTPTR(text)
    FROM #Temporary
    WHERE id=@id
--* GET THE FIRST INDEX OF OUR PATTERN
    SELECT
        @index = PATINDEX('%'+@For+'%', text)
    FROM #Temporary
    WHERE id=@id

--* IF WE FOUND ANY ENTRIES, LOOP UNTIL WE REPLACE ALL OF THEM
    IF @index > 0
    BEGIN
        select @count = 0
        WHILE (
            SELECT
                PATINDEX('%'+@For+'%', text)
                FROM #Temporary
            WHERE id=@id
              ) > 0
        BEGIN
--* KEEP A RUNNING TOTAL OF IDENTIFIED ENTRIES FOR LENGTH CHECKSUM
            select @count = @count + 1
            SELECT
            @index = PATINDEX('%'+@For+'%', text)-1
            FROM #Temporary
            WHERE id=@id

--* UPDATE THE TEMPORARY VALUE        
            UPDATETEXT #Temporary.text @pointer @index @lenFor @With
        END
--* UPDATE THE TEMPORARY RECORD, SET LENGTH AND CLENGTH VALUES FOR CHECKSUM
        UPDATE #Temporary set
            length=datalength(text),
            cLength=datalength(oldtext) - @count * @diff 
        WHERE id=@id
    END
    FETCH NEXT FROM irows INTO @id
END

CLOSE irows
DEALLOCATE irows
--* UPDATE THE DATABASE FOR ALL RECORDS IN THE TEMPORARY
--* WHERE THE CHECKSUM LENGTH MATCHED THE RESULT LENGTH
UPDATE target set
    target.DesktopHtml = t.[text]
FROM 
    YOURQUALIFIER_HtmlText target JOIN #Temporary t
    ON
        target.ModuleId = t.id AND
        t.length = t.cLength

--* DELETE ALL RECORDS FROM TEMPORARY WHICH WERE SUCCESSFUL
DELETE from #Temporary where length=clength

--* RETURN ALL ROWS WHICH FAILED LENGTH COMPARISON
--* THIS SHOULD ALWAYS BE EMPTY
select * from #Temporary

--* DROP THE TEMP TABLE AND EXIT
DROP TABLE #Temporary

greenflash
Nuke Active Member
Nuke Active Member
Posts:27

23 Feb 2008 2:35 AM  
is this method still working with DNN 4.8? I got "There is an error in your query". And my objectQualifier is empty.

DotNetNuke Help for beginners
DavidWSnow
DNN Creative Magazine Subscriber
Nuke Master
Nuke Master
Posts:124

23 Feb 2008 10:02 AM  
I routinely clone my production site on my localhost and use this proceedure every time.

I never modified it at all. I did create the stored proceedure in the database, so that it would be available on my clone when I needed it.

I run DNN 4.8 and it works with it.

/Dave
jncraig
DNN Creative Staff
Nuke Master II
Nuke Master II
Posts:2357


23 Feb 2008 10:41 AM  
I would like to recommend the FREE module, f3, from Engage Software. This installs as a module and you place it on a page accessible to administrators. Then, you can visit that page and do search and replace from inside of DotNetNuke.

Joe Craig
DNN Creative Support
Subscribe to the website
greenflash
Nuke Active Member
Nuke Active Member
Posts:27

23 Feb 2008 1:49 PM  
I tried to create stored procedure from DNN Host menu and i think it didn't creat correctly. Will digg in again.

Thanks.

DotNetNuke Help for beginners
jncraig
DNN Creative Staff
Nuke Master II
Nuke Master II
Posts:2357


24 Feb 2008 9:49 AM  
If you want to do something like that, you'll want to check the box labelled "Run as script" before you click the execute button.

If you need to lots of things like that, you should see if you can access your database directly using SQL Management Studio or the free Express version.

Joe Craig
DNN Creative Support
Subscribe to the website
salemadmin
DNN Creative Magazine Subscriber
Nuke Newbie
Nuke Newbie
Posts:1

23 Jun 2008 10:27 AM  
I am running into an issue with the latest version of DNN 4.8.4. When I run the procedure I get the following SQL error.

Msg 208, Level 16, State 1, Procedure Replace_DesktopHtml, Line 37
Invalid object name 'HtmlText'.

The same procedure works with my 4.8.2 sites, just not the 4.8.4 site. Did the devs change the object name up or is there something else I am missing?

Thanks
leesykes
DNN Creative Staff
Nuke Master III
Nuke Master III
Posts:3351

25 Jun 2008 6:06 AM  
I've just tested it in 4.8.4 and didn't get any errors, perhaps try setting it up again, thanks,

Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/leesykes

Lee Sykes's Facebook Profile
jncraig
DNN Creative Staff
Nuke Master II
Nuke Master II
Posts:2357


25 Jun 2008 8:29 AM  
Yes, I'd try running the upgrade again. It would seem that the database didn't get properly updated.

Joe Craig
DNN Creative Support
Subscribe to the website
You are not authorized to post a reply.
Forums > Users Lounge > DNN Creative Articles > Issue 22 Replace_DesktopHTML



ActiveForums 3.7

Latest Forum Posts

Yahoo Answers by cdtguru
Hey, i was wondering if anyone knew of a module that would create a similar system to Yahoo Answers...
(catalook) Itempane changes on product pages ?? by Gaz35
Hi , hi , I don’t know if you can help me , here is the site in question http...
RE: Virtual Pc 2007 help by jeff@zina.com
You need to get the Virtual PC's network set up.  Might check the Virtual PC news group: http://www...
DNNCreative Just Keeps Getting Better by jeff@zina.com
Kudos on issue 39, the article on importing large quantities of data was both timely for me and spot...
RE: Videos by clippy
Hello from France My question is about the videos for beginners, and specially n° 3; I'm working...
skinning trouble by derpir
HelloI have uploaded a skin to my DNN-website, but I want to make som changes. I have made some chan...
RE: Column width in UDT by VickySwift
In case anyone else is looking for the answer to this, I have been able to add the headers back in b...
RE: search not working by jncraig
Did you either reindex the site to turn on the scheduled task to do it?
RE: Template Issue by jncraig
No, you need to install your custom modules before you use the template.
RE: error message in registration page by jncraig
I'm not sure that you can avoid them, short of rewriting the module.You might want to investigate Dy...
Template Issue by Bobbyjosephg
Hi,   Today I have come up with a problem with templates.I was successful in exporting a template an...
RE: search not working by sanju_k1421
I checked     host==>admin search  page   that is set both limits min //max  page     still i m n...
RE: error message in registration page by coder247
but how do I avoid the error messages provided by default in dnn?
RE: Style sheet does nothing by andorz
Oh. I was told to do that in my thread at the dotnetnuke.com forum. http://www.dotnetnuke.com/Commun...
RE: Videos by clippy
Thank you to answer so quickly. It's really kind from you. I appreciate
RE: Simple subscribe newsletter module by jncraig
I seem to recall that DataSprings has an "Opt In" module. I haven't used it, though.
RE: Videos by jncraig
No, you can view them in any order.
RE: Skim Question by tlsadler
Wow! Went to Snowcovered and the 50% off Promo more then paid for itself. I actually wound up buying...
Videos by clippy
Hello from FranceJust a little questionIs there any order to respect to look the videos ("issues"). ...
RE: Skim Question by tlsadler
Thank you very much. I've followed many of your posts and will check it out. I had thought about get...
AppTheory
RSS Feeds