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:3325

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:2318


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:2318


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:3325

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:2318


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

RE: Reversing Limited Access to the Admin Menu by wynnjon
OK-So I've updated the TABS table entries in the database and set the previously modified entries (t...
RE: localhost Install issues by leesykes
If you go to the subscribe page and click on the get free trial button - this takes you to a page wh...
localhost Install issues by cdees
I've set up a local host and want to run DNN for a local development machine.  The host is set up; h...
RE: Reversing Limited Access to the Admin Menu by wynnjon
That is what I thought.  So for my clients that will need to manage user accounts, I can not limit t...
RE: Reversing Limited Access to the Admin Menu by leesykes
I seem to recall it doesn't work
RE: Reversing Limited Access to the Admin Menu by wynnjon
Thanks Lee-  I will give that a try.An additional question- If you place the "User Accounts" page un...
RE: Reversing Limited Access to the Admin Menu by leesykes
all you need to do is reverse the process within the SQL tables.Compare the data to the other rows i...
RE: Module not working when logged off. by leesykes
thanks for the info,
Reversing Limited Access to the Admin Menu by wynnjon
Hi!  I followed the tutorial for limiting the access to the admin menu.  What a great thing!However,...
RE: Trouble installing! Designer trying to be a Developer. by leesykes
glad to hear you found a solution, thanks,
RE: Skim Question by leesykes
You could but you will not be able to have an XHTML compliant page as the SolpartMenu is non-complia...
RE: Include in Menu - Weird Request by leesykes
For your sitemap.xml file - use GSiteCrawlerYou could create the site map before moving the sub menu...
RE: Trouble installing! Designer trying to be a Developer. by awright14
It looks like I had ASP installed in the wrong order.  Copying and pasting this into the Run Command...
RE: Need Help Changing Containers Contentpane's Text Color by leesykes
Hello,Have you tried adding a class to the content area of your container and then styling the p, a,...
RE: Vertical SolpartMenu by leesykes
hello,If you wish to display the admin and host menus within the house menu, you need to enable it i...
RE: Firefox Does Not Display WMV File In Media Module by leesykes
Hello,I have just tested this and I can play a wmv file in Firefox 3.0.3, so it does suggest that it...
RE: advice wanted convert site to DNN while keeping existing asp functionality by leesykes
You could try using the IFrame module in DotNetNuke and then just link the IFrame to the current pag...
RE: Need Help Changing Containers Contentpane's Text Color by CROKeefe
Thanks for the quick update... I know it looks broken right now, but I had the TITLE classes working...
RE: Need Help Changing Containers Contentpane's Text Color by leesykes
The default class for a container is .head so you will find that the .head class will override any s...
RE: Module not working when logged off. by t.ramya85
have to set the cache time to '0' in that module setting.
AppTheory
RSS Feeds