If you are having problems with the Order of you tabs within your menu system not matching the order of the tabs as they are represented within the Tab Pages Admin menu it is probably due to an errant update or insert into the Tabs table within DotNetNuke. If this is the case, or if something else has caused this odd behavior there is a simple SQL script you can execute to correct the table.
A client posed this problem with their database upon completion of a number of automated insert processes migrating Tabs and Modules from one DNN instance into another. The following script identifies all the Tabs, the order they currently are marked to appear, and their heirarchy and successfully renumbers them in an appropriate fashion. The ordering will not override the pages that have been identified as Administrative tabs based on their tab order (larger than 10000). Execute this script within your Host SQL tab, or an external connection to your database.
You will probably need to restart the site either manually or force an automatic restart by changing a runtime component (we prefer to simply rename the web.config file, and immediatly set the name back to web.config which issues a restart of the site and clears its runtime cache).
Use the following code to correct your tab/page ordering:
declare @CurrentID int declare @ParentID int
create table #NewTabs(TabID int, ParentID int, OldTabOrder int, NewTabOrder int, [Auto] int identity(1,1), Done bit) create table #Tabs2(TabID int)
select @CurrentID = (Select top 1 TabID from Tabs where isDeleted = 0 AND ParentID is null and TabID not in (Select TabID from #NewTabs) order by TabOrder) WHILE not @CurrentID is null BEGIN INSERT INTO #NewTabs(TabID,ParentID, OldTabOrder, Done) SELECT TabID, ParentID, TabOrder, 0 FROM Tabs where TabId = @CurrentID
WHILE not @CurrentID is null BEGIN INSERT INTO #Tabs2(TabID) Select TabID from Tabs WHERE isDeleted = 0 AND ParentID = @CurrentID
Update #NewTabs set Done = 1 where TabID = @CurrentID
Select @CurrentID = (Select top 1 TabID from #NewTabs where Done = 0 ORDER BY OldTabOrder) IF @CurrentID is null BEGIN INSERT INTO #NewTabs(TabID,ParentID, OldTabOrder, Done) SELECT t2.TabID,t.ParentID, t.TabOrder,0 FROM #Tabs2 t2 JOIN Tabs t on t.TabID = t2.TabID AND t.isDeleted = 0 ORDER BY t.TabOrder
TRUNCATE TABLE #Tabs2
Select @CurrentID = (Select top 1 TabID from #NewTabs where Done = 0 ORDER BY OldTabOrder) print @CurrentID END END select @CurrentID = (Select top 1 TabID from Tabs where isDeleted = 0 AND ParentID is null and TabID not in (Select TabID from #NewTabs) order by TabOrder) END UPDATE #newTabs set NewTabOrder = [Auto] where OldTaborder < 10000 UPDATE #newTabs set NewTabOrder = OldTabOrder where OldTabOrder >= 10000
UPDATE t set t.TabOrder = n.NewTabOrder from Tabs t JOIN #NewTabsn on t.TabId = n.TabID
drop table #newtabs drop table #tabs2 |