Kentico 7 DB 查找未使用的 CMSWebparts
Kentico 7 DB Find Unused CMSWebparts
我有一个网站,开发人员在其中创建了 30 个 ascx 文件副本并将它们注册为 Web 部件。我希望能够查询 Kentico 数据库并找出网站上有哪些内容并将 Web 部件与文件名相关联。换句话说,运行 一个将 ascx 文件与活动页面相关联的查询。
我做的一个查询在 XML 中显示了这个嵌入在 table 中:
此 guid 存储在数据库中的什么位置?我在这里错过了一个协会,这让我发疯。我无法从 CMS Desk 确定哪个 web ascx 文件对应于每个活动页面。
您可以使用以下查询。
它将列出 WebPart ASCX 文件的物理位置路径、使用它的页面的 NodeAliasPath,以及 WebPart 所在页面模板的代码名称。您可以根据自己的喜好调整所选列。
SELECT DISTINCT
WP.WebPartFileName, -- Physical location of the webpart file
NodeAliasPath, -- Alias path of the page that uses the webpart
PageTemplateCodeName -- Code name of the template that contains the webpart
FROM CMS_WebPart WP
INNER JOIN
(
-- Convert the PageTemplateWebParts column to XML
-- Get the 'type' attribute from all 'webpart' elements, as the 'WebPartName' column
SELECT
PageTemplateID,
PageTemplateCodeName,
T.N.value('@type', 'varchar(50)') as WebPartName
FROM CMS_PageTemplate
CROSS APPLY (SELECT CAST(PageTemplateWebParts AS XML)) as X(X)
CROSS APPLY X.X.nodes('/page/*/webpart') T(N)
) TemplateWebParts ON WP.WebPartName = TemplateWebParts.WebPartName
-- Join the Tree view, to get NodeAliasPaths of pages that use the template
INNER JOIN View_CMS_Tree_Joined T ON T.NodeTemplateID = TemplateWebParts.PageTemplateID
ORDER BY NodeAliasPath
在 Kentico 中,WebParts 位于页面模板上,然后与页面相关联。
它们可以在 PageTemplateWebParts
列中作为 XML 在它们的设置旁边找到。
webpart
元素的 type
属性等同于 CMS_WebPart
table.
中的 WebPartName
列
我有一个网站,开发人员在其中创建了 30 个 ascx 文件副本并将它们注册为 Web 部件。我希望能够查询 Kentico 数据库并找出网站上有哪些内容并将 Web 部件与文件名相关联。换句话说,运行 一个将 ascx 文件与活动页面相关联的查询。
我做的一个查询在 XML 中显示了这个嵌入在 table 中:
此 guid 存储在数据库中的什么位置?我在这里错过了一个协会,这让我发疯。我无法从 CMS Desk 确定哪个 web ascx 文件对应于每个活动页面。
您可以使用以下查询。 它将列出 WebPart ASCX 文件的物理位置路径、使用它的页面的 NodeAliasPath,以及 WebPart 所在页面模板的代码名称。您可以根据自己的喜好调整所选列。
SELECT DISTINCT
WP.WebPartFileName, -- Physical location of the webpart file
NodeAliasPath, -- Alias path of the page that uses the webpart
PageTemplateCodeName -- Code name of the template that contains the webpart
FROM CMS_WebPart WP
INNER JOIN
(
-- Convert the PageTemplateWebParts column to XML
-- Get the 'type' attribute from all 'webpart' elements, as the 'WebPartName' column
SELECT
PageTemplateID,
PageTemplateCodeName,
T.N.value('@type', 'varchar(50)') as WebPartName
FROM CMS_PageTemplate
CROSS APPLY (SELECT CAST(PageTemplateWebParts AS XML)) as X(X)
CROSS APPLY X.X.nodes('/page/*/webpart') T(N)
) TemplateWebParts ON WP.WebPartName = TemplateWebParts.WebPartName
-- Join the Tree view, to get NodeAliasPaths of pages that use the template
INNER JOIN View_CMS_Tree_Joined T ON T.NodeTemplateID = TemplateWebParts.PageTemplateID
ORDER BY NodeAliasPath
在 Kentico 中,WebParts 位于页面模板上,然后与页面相关联。
它们可以在 PageTemplateWebParts
列中作为 XML 在它们的设置旁边找到。
webpart
元素的 type
属性等同于 CMS_WebPart
table.
WebPartName
列