Question

I have tried the answer suggested on the Ektron forums at 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.

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?

Was it helpful?

Solution

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

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. The manager does work as expected, returning all associated aliases, when using the Alias Criteria objects located in 'Ektron.Cms.Settings.UrlAliasing.DataObjects.AliasCriteria'. Objects returned are generic to alias type, and will indicate if they are a default with the isDefault property.

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);

OTHER TIPS

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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top