Copying settings between DNNArticle modules
ZLDNN's DNNArticle is a really cool article module, loaded with a ton of features. Unfortunately, sometimes you'll have to add more than one modules on your site, and a ton of features typically comes with a ton of settings. In order not to have a hard time setting all the options from scratch, here is a script you can use to copy all those nifty settings you'll find in the "DNNArticle Settings" area from an already existing module.
You need to know three things: The source and destination module ids (NOT the tab ids, the actual module ids) and the tab id which will be used for the presentation of an article.
In the script given, I'm copying settings from module id 430 to module id 1232, with a view tab id of 986. Be sure to put your own numbers there.
Also, before running the script, make sure you have visited the settings area of the (newly added) DNNArticle module to be updated and have pressed "update" there (even if you haven't changed anything) so that the corresponding records are created in the ModuleSettings table.
The script is fairly straightforward, use at your own risk as always. Enjoy.
------------------------------------------------------
Start of values to be changed each run
------------------------------------------------------
*/
-- This is the module id we are copying settings FROM
declare @originalmodule int
set @originalmodule=430
-- This is the module id we are copying settings TO
declare @moduletobeupdated int
set @moduletobeupdated = 1232
-- This is the view tab id for the module we are updating, in case it is
-- different than the one of the source module.
declare @viewtab int
set @viewtab=986
/*
------------------------------------------------------
End of values to be changed each run
------------------------------------------------------
*/
-- Some variables to hold table data
declare @settingname nvarchar(50)
declare @settingvalue nvarchar(2000)
-- Get a cursor and start updating
declare cur cursor fast_forward for
select
settingname
,settingvalue
from
modulesettings
where
moduleid=@originalmodule
open cur
fetch next from cur into @settingname, @settingvalue
while @@fetch_status=0
begin
if @settingname='ViewTab'
begin
update
modulesettings
set
settingvalue=@viewtab
where
settingname=@settingname and moduleid=@moduletobeupdated
end
else
begin
update
modulesettings
set
settingvalue=@settingvalue
where
settingname=@settingname and moduleid=@moduletobeupdated
end
fetch next from cur into @settingname, @settingvalue
end
close cur
deallocate cur
0 comments:
Post a Comment