1

我有一批从 umbraco (4.7) 数据库中加载一些信息。

我需要提取Link to document节点属性...

站点中的 Api 确实如此umbraco.library.NiceUrl(nodeid)……但我有一个控制台应用程序无法访问 umbraco 的东西……

1)我在哪里可以找到数据库中节点的这个“不错的 url”?
2)如果不是(或太复杂),如何使用控制台应用程序配置 umbraco API (4.7) 库?

4

3 回答 3

2

我尝试了上述答案,但它们需要 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 */
于 2016-09-16T12:49:34.217 回答
1
    SELECT 
    cast([xml] as xml).query('data(//@urlName[1])').value('.', 'varchar(20)') AS PATH
    FROM cmsContentXml where nodeid = 19802

我的 2 美分值

于 2016-04-29T08:10:31.620 回答
0
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;
于 2015-08-19T22:48:19.367 回答