Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Clone A Menu Into Multiple Languages

Posted on October 23, 2013October 26, 2015 By David Kittell
BEGIN TRANSACTION

CREATE TABLE #NewMenu (
	[mnu_id] [bigint] NOT NULL
	,[mnu_name] [nvarchar](255) NULL
	,[mnu_description] [nvarchar](255) NULL
	,[folder_id] [bigint] NOT NULL
	,[recursive] [int] NOT NULL
	,[user_id] [bigint] NULL
	,[date_created] [datetime] NOT NULL
	,[last_edit_date] [datetime] NULL
	,[last_edit_lname] [nvarchar](50) NOT NULL
	,[last_edit_fname] [nvarchar](50) NOT NULL
	,[mnu_type] [int] NOT NULL
	,[mnu_link] [nvarchar](255) NULL
	,[template_link] [nvarchar](255) NULL
	,[parent_id] [bigint] NULL
	,[ancestor_id] [bigint] NULL
	,[content_language] [int] NOT NULL
	,[mnu_image] [nvarchar](512) NULL
	,[mnu_image_override] [int] NULL
	,[mnu_to_folders] [nvarchar](512) NULL
	,[mnu_to_templates] [nvarchar](255) NULL
	,[dynamic_replication_method] [int] NULL
	)
GO

WITH MenuCTE
AS (
	SELECT *
	FROM [dbo].[menu_tbl]
	WHERE [mnu_id] = 60 -- MENUID TO CLONE
		AND [content_language] = 2057 -- LANGUAGE OF MENU TO CLONE

	UNION ALL

	SELECT [dbo].[menu_tbl].*
	FROM [dbo].[menu_tbl]
	INNER JOIN MenuCTE ON MenuCTE.mnu_id = [dbo].[menu_tbl].[ancestor_id]
		AND MenuCTE.content_language = [dbo].[menu_tbl].content_language
		AND MenuCTE.[ancestor_id] != [dbo].[menu_tbl].mnu_id
	)
-- Clone menu
INSERT INTO #NewMenu (
	[mnu_id]
	,[mnu_name]
	,[mnu_description]
	,[folder_id]
	,[recursive]
	,[user_id]
	,[date_created]
	,[last_edit_date]
	,[last_edit_lname]
	,[last_edit_fname]
	,[mnu_type]
	,[mnu_link]
	,[template_link]
	,[parent_id]
	,[ancestor_id]
	,[content_language]
	,[mnu_image]
	,[mnu_image_override]
	,[mnu_to_folders]
	,[mnu_to_templates]
	,[dynamic_replication_method]
	)
SELECT [mnu_id]
	,UPPER([L].[browser_code]) + ' ' + [mnu_name]
	,[mnu_description]
	,[folder_id]
	,[recursive]
	,[user_id]
	,[date_created]
	,[last_edit_date]
	,[last_edit_lname]
	,[last_edit_fname]
	,[mnu_type]
	,[mnu_link]
	,[template_link]
	,[parent_id]
	,[ancestor_id]
	,[L].language_id --[content_language]
	,[mnu_image]
	,[mnu_image_override]
	,[mnu_to_folders]
	,[mnu_to_templates]
	,[dynamic_replication_method]
FROM MenuCTE
INNER JOIN language_type [L] ON [L].language_id IN (
		1033
		,1036
		,1034
		,2052
		,1031
		,1040
		,1046
		,1049
		) -- LANGUAGES TO CLONE INTO

-- Conflicting Rows
SELECT *
FROM #NewMenu [NM]
INNER JOIN [menu_tbl] [M] ON [NM].mnu_id = [M].mnu_id
	AND [NM].content_language = [M].content_language

/*  uncomment this block when ready to add new menus!
 INSERT INTO [menu_tbl]([mnu_id]
       ,[mnu_name]
       ,[mnu_description]
       ,[folder_id]
       ,[recursive]
       ,[user_id]
       ,[date_created]
       ,[last_edit_date]
       ,[last_edit_lname]
       ,[last_edit_fname]
       ,[mnu_type]
       ,[mnu_link]
       ,[template_link]
       ,[parent_id]
       ,[ancestor_id]
       ,[content_language]
       ,[mnu_image]
       ,[mnu_image_override]
       ,[mnu_to_folders]
       ,[mnu_to_templates]
       ,[dynamic_replication_method] )
 SELECT [mnu_id]
       ,[mnu_name]
       ,[mnu_description]
       ,[folder_id]
       ,[recursive]
       ,[user_id]
       ,[date_created]
       ,[last_edit_date]
       ,[last_edit_lname]
       ,[last_edit_fname]
       ,[mnu_type]
       ,[mnu_link]
       ,[template_link]
       ,[parent_id]
       ,[ancestor_id]
       ,[content_language]
       ,[mnu_image]
       ,[mnu_image_override]
       ,[mnu_to_folders]
       ,[mnu_to_templates]
       ,[dynamic_replication_method]
 FROM #NewMenu

 INSERT INTO [menu_to_item_tbl]([mnu_id]
       ,[item_id]
       ,[item_type]
       ,[item_title]
       ,[item_link]
       ,[item_target]
       ,[order_loc]
       ,[item_description]
       ,[link_type]
       ,[id]
       ,[content_language]
       ,[item_image]
       ,[item_image_override])
 SELECT [MI].[mnu_id]
       ,[item_id]
       ,[item_type]
       ,[item_title]
       ,[item_link]
       ,[item_target]
       ,[order_loc]
       ,[item_description]
       ,[link_type]
       ,[id]
       ,[NM].[content_language]
       ,[item_image]
       ,[item_image_override]
 FROM [dbo].[menu_to_item_tbl] [MI]
 INNER JOIN #NewMenu [NM] ON [MI].mnu_id=[NM].mnu_id

 */
-- INSERTED ROWS
SELECT *
FROM #NewMenu

SELECT [MI].[mnu_id]
	,[item_id]
	,[item_type]
	,[item_title]
	,[item_link]
	,[item_target]
	,[order_loc]
	,[item_description]
	,[link_type]
	,[id]
	,[NM].[content_language]
	,[item_image]
	,[item_image_override]
FROM [dbo].[menu_to_item_tbl] [MI]
INNER JOIN #NewMenu [NM] ON [MI].mnu_id = [NM].mnu_id

DROP TABLE #NewMenu

ROLLBACK TRANSACTION -- keep in place until 100% happy!
	-- COMMIT TRANSACTION -- remove comment when ready!

Source: http://www.codeproject.com/Articles/275767/Ektron-SQL-Script-To-Clone-A-Menu-into-Multiple-La

Originally Posted on October 23, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code Ektron MSSQL MSSQL - Ektron MSSQL - Ektron 8.0.2 SQL

Post navigation

Previous post
Next post

Related Posts

PowerShell – Show File Extensions

Posted on August 30, 2016

function ShowFileExtensions() { # http://superuser.com/questions/666891/script-to-set-hide-file-extensions Push-Location Set-Location HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced Set-ItemProperty . HideFileExt "0" Pop-Location Stop-Process -processName: Explorer -force # This will restart the Explorer service to make this work. } ShowFileExtensions function HideFileExtensions() { # http://superuser.com/questions/666891/script-to-set-hide-file-extensions Push-Location Set-Location HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced Set-ItemProperty . HideFileExt "1" Pop-Location Stop-Process -processName: Explorer -force # This will…

Read More

Azure PowerShell – Get Static IP of Azure VMs

Posted on July 11, 2016

Get-AzureVM | Select-Object -Property Name, @{Name=’StaticIP’;Expression={(Get-AzureStaticVNetIP -VM $_ ).IPAddress}} All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what…

Read More

UNIX – Pi-Hole Project – Statistics

Posted on April 21, 2017June 10, 2019

If you are using Pi-Hole you may find this script useful Currently this is designed to run on the server that is running Pi-Hole but as I have more than one I want to monitor I will soon have an update for additional. First make sure you update your /var/www/html/admin/scripts/pi-hole/php/data.php…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes