簡體   English   中英

從Umbraco(4.7)數據庫獲取節點URl

[英]Get the Node URl from the Umbraco (4.7) Database

我有一批從umbraco(4.7)數據庫中加載一些信息。

我需要提取Link to document節點屬性...

該站點中的Api就像umbraco.library.NiceUrl(nodeid) ...但是我有一個控制台應用程序,該應用程序不具有umbraco的權限...

1)在哪里可以找到數據庫中節點的“ nice url”?
2)如果不是(或太復雜),如何通過控制台應用程序配置umbraco API(4.7)庫?

我嘗試了上述答案,但它們需要mysql(需要sql server),clr函數,或僅包含有關當前文檔的url信息的信息。 對於導航路徑深處的兒童和文檔,我想包括完整路徑。 以下對我有用

; WITH PathXml AS (

    /* -- This just gives nodes with their 'urlName' property
       -- not in recycle bin, 
       -- level > 1 which excludes the top level documents which are not  included in the url */
    SELECT 
        nodeId,
        cast([xml] as xml).query('data(//@urlName[1])').value('.', 'varchar(max)') AS Path
    FROM cmsContentXml x
    JOIN umbracoNode n ON x.nodeId = n.id AND n.trashed = 0 AND n.level > 1
)

SELECT
    un.id,
    un.path,
    '/' + 
    /* IsNull after the leading '/'. This will handle the top level document */
    IsNull((SELECT 
                pl.Path + '/'  /* Ok to end with a / */
             FROM PathXml pl 

             /* e.g. ',-1,1071,1072,1189,' LIKE '%,1072,%' */
             WHERE ',' + un.path + ',' LIKE '%,' + CAST(pl.nodeId AS VARCHAR(MAX)) + ',%'

             /* order by the position of ',1072,' in ',-1,1071,1072,1189,' */
             ORDER BY CHARINDEX(',' + CAST(pl.nodeId AS VARCHAR(MAX)) + ',',
                                ',' + un.path + ',')

             FOR XML PATH('')), 
    '') AS Url,
    un.text PageName
FROM umbracoNode un
WHERE nodeObjectType = 'C66BA18E-EAF3-4CFF-8A22-41B16D66A972' /* "Document" https://our.umbraco.org/apidocs/csharp/api/Umbraco.Core.Constants.ObjectTypes.html#Umbraco_Core_Constants_ObjectTypes_Document */
AND trashed = 0
ORDER BY 3 /* Url */
    SELECT 
    cast([xml] as xml).query('data(//@urlName[1])').value('.', 'varchar(20)') AS PATH
    FROM cmsContentXml where nodeid = 19802

我的2美分價值

select 
    GROUP_CONCAT(EXTRACTVALUE(xml, "//@urlName") separator '/') as PATH
from 
    cmscontentxml x inner join 
    umbraconode n on FIND_IN_SET(x.NODEID,n.PATH)>0
where n.ID=19802 -- your id
group by n.ID;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM