在 Sitefinity 数据库中查找其他 url 列表

Find list of additional urls in Sitefinity database

有谁知道我可以使用什么 SQL 在 Sitefinity 数据库中查找某个站点的所有其他 URL?

我能够使用以下 sql.

创建一个 url 列表以及关联的页面和父页面(使用两者的 html_title)
SELECT ud.url,
pd.html_title_, ppd.html_title_ AS ParentHtmlTitle
FROM sf_url_data ud INNER JOIN sf_page_node pn ON ud.id2 = pn.id
INNER JOIN sf_page_data pd ON pn.content_id = pd.content_id
INNER JOIN sf_page_node ppn ON pn.parent_id = ppn.id
INNER JOIN sf_page_data ppd ON ppn.content_id = ppd.content_id
ORDER BY ud.url

我缺少的部分是,虽然 sf_url_data 有一个 content_id 字段,但它并不总是对应于适当的页面。但是,table 中的字段 id2 确实对应于 sf_page_node table,其中包含 sf_page_data table 的相应 content_id。

这是我最终为我们的场景得出的结论。 wbg34 的查询并没有给我用户实际导航到的真实结果 url,因为这是由您在 sitefinity 中设置的页面层次结构决定的。所以我所做的是通过最多增加 8 个深度级别在下面的查询中构建 FinalUrl,如果您需要更多,只需向查询添加更多级别。

此查询删除特殊后端页面,并从 FinalUrl 中的 url 中删除前面的 "Pages"。它列出了所有重定向行 (IsRedirect = 1),或者如果您在带有 (IsRedirect = 0) 的页面上看到多个 url,这意味着它是该页面的替代 URL 而不是重定向。

select right(
stuff(FinalUrl,len(finalurl),1,''), len(finalurl)-6) --Remove trailing slash and Pages from beginning of URL
, url RedirectUrl, redirect IsRedirect, title_ as Title from (
select 
concat(ppn8.url_name_ + '/',ppn7.url_name_ + '/',ppn6.url_name_ + '/',ppn5.url_name_ + '/', ppn4.url_name_+ '/', ppn3.url_name_+ '/', ppn2.url_name_+ '/', ppn.url_name_+ '/', pn.url_name_+ '/')
FinalUrl, ud.url, ud.redirect, pn.title_ from sf_url_data ud 
INNER JOIN sf_page_node pn ON ud.id2 = pn.id
left outer join sf_page_node ppn ON pn.parent_id = ppn.id
left outer join sf_page_node ppn2 ON ppn.parent_id = ppn2.id
left outer join sf_page_node ppn3 ON ppn2.parent_id = ppn3.id
left outer join sf_page_node ppn4 ON ppn3.parent_id = ppn4.id
left outer join sf_page_node ppn5 ON ppn4.parent_id = ppn5.id
left outer join sf_page_node ppn6 ON ppn5.parent_id = ppn6.id
left outer join sf_page_node ppn7 ON ppn6.parent_id = ppn7.id
left outer join sf_page_node ppn8 ON ppn7.parent_id = ppn8.id
) a
where FinalUrl not like 'Backend%'
order by FinalUrl

Progresses 知识库文章提供了这些额外的指针,但不提供页面的最终 url。

--PageName, PageUrl, EnableMultipleUrl, SearchEngineTitle 
SELECT pn.[title_]              AS PageName, 
       pn.[url_name_]           AS PageUrl, 
       pn.[allow_multiple_urls] AS EnableMultipleUrl, 
       (SELECT Count(*) 
        FROM   (SELECT url, 
                       Row_number() 
                         OVER( 
                           partition BY url 
                           ORDER BY url DESC) rn 
                FROM   [dbo].[sf_url_data] 
                WHERE  id2 = pn.id) a 
        WHERE  rn = 1)          AS AdditionalUrlsCount, 
       pd.[html_title_]         AS SearchEngineTitle 
FROM   [dbo].[sf_page_node] AS pn 
       JOIN [dbo].[sf_page_data] AS pd 
         ON pn.content_id = pd.content_id 
-- if only frontend pages 
WHERE  pn.root_id = 'F669D9A7-009D-4D83-DDAA-000000000002' -- default frontend root id 

--PageName, PageUrl, EnableMultipleUrl, SearchEngineTitle 
SELECT pn.[title_]                  AS PageName, 
       pn.[url_name_]               AS PageUrl, 
       pn.[allow_multiple_urls]     AS EnableMultipleUrl, 
       (SELECT Count(*) 
        FROM   (SELECT url, 
                       Row_number() 
                         OVER( 
                           partition BY url 
                           ORDER BY url DESC) rn 
                FROM   [dbo].[sf_url_data] 
                WHERE  id2 = pn.id) a 
        WHERE  rn = 1)              AS AdditionalUrlsCount, 
       (SELECT TOP 1 Substring((SELECT ',' + ST1.url AS [text()] 
                                FROM   (SELECT url 
                                        FROM   (SELECT url, 
                                                       Row_number() 
                                                         OVER( 
                                                           partition BY url 
                                                           ORDER BY url DESC) rn 
                                                FROM   [dbo].[sf_url_data] 
                                                WHERE  id2 = pn.id) a 
                                        WHERE  rn = 1) ST1 
                                FOR xml path ('')), 2, 1000) AS [Urls] 
        FROM   (SELECT * 
                FROM   (SELECT url, 
                               Row_number() 
                                 OVER( 
                                   partition BY url 
                                   ORDER BY url DESC) rn 
                        FROM   [dbo].[sf_url_data] 
                        WHERE  id2 = pn.id) a 
                WHERE  rn = 1) ST2) AS Urls, 
       pd.[html_title_]             AS SearchEngineTitle 
FROM   [dbo].[sf_page_node] AS pn 
       JOIN [dbo].[sf_page_data] AS pd 
         ON pn.content_id = pd.content_id 
-- if only frontend pages 
WHERE  pn.root_id = 'F669D9A7-009D-4D83-DDAA-000000000002' -- default frontend root id