Set additional document alias API

Digital Team asked on December 14, 2016 13:02

Hi,

Im trying to add additional aliases like you can do in the CMSDESK but with the API and I have no luck.

I'm trying this but it doesn't update the document.

DocumentAliasInfo dai = new DocumentAliasInfo(); dai.AliasURLPath = aditionalAlias; dai.AliasCulture = "en-us"; dai.AliasSiteID = CMS.SiteProvider.SiteInfoProvider.CurrentSiteID; dai.AliasNodeID = node.NodeID;

node.Aliases.Add(dai);

This is bases on https://devnet.kentico.com/forums/f48/fp5/t20637/how-to-add-additional-document-aliases-using-th

But dont work either.

If somebody can get me documentation for this I would appreciete.

Kind regards

Recent Answers


Roman Hutnyk answered on December 14, 2016 13:09

It looks like you haven't saved your DocumentAliasInfo object. I think you have to save it right before you call

node.Aliases.Add(dai);

I might be wrong as I'm now sure how it works in Kentico 7

1 votesVote for this answer Mark as a Correct answer

Anton Grekhovodov answered on December 14, 2016 13:40 (last edited on December 14, 2016 13:43)

There is a documentation how to use API for this purpose Creating a page alias. Just read it. And I think it's the same for Kentico 7. You need to save DocumentAliasInfo without adding it to TreeNode item, because DocumentAliasInfo item already has AliasNodeID property which is a link to your node.

1 votesVote for this answer Mark as a Correct answer

Digital Team answered on December 14, 2016 15:00

It worked using dai.Insert(); after building the object.

Regards

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.