Hi.
I am trying to update links in xhtml-content during the SavingContent event using the IContentSoftLinkRepository, but cant seem to get it to work. I have been unable to track down any documentation for it so I have just been playing around, trying and failing. One of my (failed) approaches included below. This one increases the number of softlinks tied to a page, but in the xhtml the link does not change.
Any and all pointers would be appreciated.
private void SavingContent(object sender, ContentEventArgs contentEventArgs)
{
var repo = ServiceLocator.Current.GetInstance<IContentSoftLinkRepository>();
var links = repo.Load(contentEventArgs.ContentLink);
var modified = new List<SoftLink>();
foreach(var link in links.Where(p => p.SoftLinkType == ReferenceType.PageLinkReference))
{
if (link.ReferencedContentLink.ID == 4121)
{
link.ReferencedContentLink = new ContentReference(1441);
modified.Add(link);
}
}
repo.Save(contentEventArgs.ContentLink,
contentEventArgs.Content.Language(),
modified,
false);
}