简体   繁体   English

在Ektron CMS 8.6+中,如何获得任意内容的有效别名?

[英]In Ektron CMS 8.6+, how can I get a valid alias for an arbitrary piece of content?

I have tried the answer suggested on the Ektron forums at http://dev.ektron.com/forum.aspx?g=posts&t=29497 我已经尝试了Ektron论坛上建议的答案, 网址http://dev.ektron.com/forum.aspx?g=posts&t=29497

these use the 这些使用

Ektron.Cms.API.UrlAliasing.UrlAliasManual

and

Ektron.Cms.API.UrlAliasing.UrlAliasAuto

objects. 对象。 However, I am working in Ektron version 8.6 sp1, and the methods GetItemForContent and GetDefaultAlias respectively throw "not implemented" exceptions, leading me to believe they no longer function. 但是,我正在使用Ektron 8.6 sp1,并且方法GetItemForContent和GetDefaultAlias分别抛出“未实现”异常,使我相信它们不再起作用。

Beyond this, it isn't even clear to me that these would work generically, as I can see no method of detecting if a particular content has a manual, automatic, or any alias without first calling those methods. 除此之外,我什至不清楚它们是否可以通用,因为在没有先调用这些方法的情况下,我看不到检测特定内容是否具有手动,自动或任何别名的方法。 Does anyone know the current best practice for retrieving these aliases? 有谁知道检索这些别名的当前最佳实践?

Alright, after some digging through workarea files (answer was in \\Workarea\\controls\\content\\UrlAliasing\\editAliasesTab.ascx.cs), the current approach uses a frameworkAPI manager object in the namespace Ektron.Cms.Framework.Settings.UrlAliasing 好吧,经过一些工作区文件的挖掘(答案在\\ Workarea \\ controls \\ content \\ UrlAliasing \\ editAliasesTab.ascx.cs中),当前方法使用命名空间Ektron.Cms.Framework.Settings.UrlAliasing的frameworkAPI管理器对象。

This object appears to be able to handle both manual and automatic aliases, although its standard "get" methods only return automatic aliases in my testing, and the getDefaultAlias method always returns an empty string. 尽管该对象的标准“ get”方法仅在我的测试中返回自动别名,并且getDefaultAlias方法始终返回一个空字符串,但它似乎能够处理手动和自动别名。 The manager does work as expected, returning all associated aliases, when using the Alias Criteria objects located in 'Ektron.Cms.Settings.UrlAliasing.DataObjects.AliasCriteria'. 使用位于“ Ektron.Cms.Settings.UrlAliasing.DataObjects.AliasCriteria”中的Alias Criteria对象时,管理器确实按预期工作,并返回所有关联的别名。 Objects returned are generic to alias type, and will indicate if they are a default with the isDefault property. 返回的对象是别名类型的通用对象,并将使用isDefault属性指示它们是否为默认对象。

The following will pull out all aliases regardless of type: 以下内容将提取所有别名,而不管类型如何:

Ektron.Cms.Framework.Settings.UrlAliasing.AliasManager aCRUD = new ektron.Cms.Framework.Settings.UrlAliasing.AliasManager();
Ektron.Cms.Settings.UrlAliasing.DataObjects.AliasCriteria aSelector = new Ektron.Cms.Settings.UrlAliasing.DataObjects.AliasCriteria();
aSelector.AddFilter(Ektron.Cms.Settings.UrlAliasing.DataObjects.AliasProperty.TargetId, Ektron.Cms.Common.CriteriaFilterOperator.EqualTo, contentId);
var allAlias = aCRUD.GetList(aSelector);

If you are looking for the direct link for content, which may be any alias then following code will work: 如果您正在寻找内容的直接链接(可以是任何别名),那么以下代码将起作用:

ContentManager cm = new ContentManager();
ContentData cd = cm.GetItem(contentId);
string link = cd.QuickLink();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM