2016-07-14 14 views
0

我有一個網站,dev已創建30個ascx文件副本並將它們註冊爲webparts。我希望能夠查詢Kentico數據庫並找出哪些在網站上直播,並將網頁部分與文件名相關聯。換句話說,運行查詢將ascx文件與活動頁面關聯起來。Kentico 7 DB查找未使用的CMSWebparts

一個查詢我做節目我這個在XML嵌入表:

哪裏是存儲在數據庫中此GUID?我在這裏錯過了一個協會,這使我瘋狂。我無法從CMS Desk確定哪個web ascx文件對應於每個活動頁面。

回答

2

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