Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
My current iteration, which permanently changes the target of the link in the softlinkrepo, but the changes are not reflected in the xhtml-field.. IE the old link is still there when I inspect the html in the wysiwyg
var links = repo.Load(contentEventArgs.ContentLink);
foreach(var link in links.Where(p => p.SoftLinkType == ReferenceType.PageLinkReference))
{
if (link.ReferencedContentLink.ID == 3134)
{
var clone = link.ReferencedContentLink.CreateWritableClone();
clone.ID = 241;
link.ReferencedContentLink = clone;
}
}
if (links.Count > 0) repo.Save(contentEventArgs.ContentLink, null, links, false);
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); }