您可以使用以下查詢。 它將列出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
表中的WebPartName
列。