November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
I encountered a similar issue to this which, for me, turned out to be down to the save action. In addition to publish, I needed additional actions to force the new page.
clone["RelatedPage"] = new PageReference(pageB_id); var saveAction = SaveAction.CheckIn | SaveAction.Publish | SaveAction.ForceNewVersion; _repository.Save((IContent)clone, saveAction, AccessLevel.NoAccess);
I'm afraid that didn't work Darren.
References are still there. When I try to delete the old page it still shows references in other pages that I know don't have reference to old page. When I manually publish these in Edit mode the reference is removed.
I'm afraid that didn't work Darren.
References are still there. When I try to delete the old page it still shows references in other pages that I know don't have reference to old page. When I manually publish these in Edit mode the reference is removed.
I would think it's correct that old versions linking to a page would still be kept as references to content. But if it works when you publish manually I guess it's not.
Could also have something to do with other language versions of the content.
Maybe you need to touch the mark as changed property?
clone["PageChangedOnPublish"] = true;
I'm afraid that didn't work either. References are still there. I'm actually already editing pages in the language that contains the reference so I believe I got that part correct at least.
There might be some clues in this thread: https://world.episerver.com/forum/developer-forum/-Episerver-75-CMS/Thread-Container/2014/11/how-to-clean-up-inactive-softlinks-from-database/
Yes, that did it for me Johan. I created a method that updates all the softlinks and it worked. However, ContentSoftLinkIndexer is unsupported internal API. So use it carefully and at your own risk. It might change without notice. So do test it after Episerver upgrade.
public void UpdateSoftLinks(List<ReferenceInformation> referenceList) { foreach (var reference in referenceList) { var content = _repository.Get<IContent>(reference.OwnerID, reference.OwnerLanguage); var links = _contentSoftLinkIndexer.GetLinks(content); _contentSoftLinkRepository.Save(content.ContentLink.ToReferenceWithoutVersion(), content is ILocalizable ? reference.OwnerLanguage : null, links, false); } }
For me this was not working but i managed to manually change the reference to the new page by adding the following code:
foreach (SoftLink link in links) { if (link.ReferencedContentLink == oldPage.ContentLink) link.ReferencedContentLink = newPage.ContentLink; }
Thank you guys.
What you want is to trigger softlink save, not replace it manually. If pages are still showing among references you might also have missed replacing some of the old page references.
In the meantime I made it work as it should. Now the softlink save is triggered. The manual update was a backup solution.
Hi there!
I have a fairly straght forward code that replaces all references to page A with reference to page B in an Episerver 11 solution. The code below is simplified.
First I loop through all references with reference to page A
Then I fetch the original page in correct language, create clone, alter and save.
All of this works. Referenced page is published and now has reference to page B. However, if I try to delete page A or run GetReferencesToContent again I will still get that Refrences page has a reference to page A. If I in Edit mode alter the referenced page and publish, the reference will finally update correctly and reference to page A is finally gone.
Am I missing something in my code that updates the references? I thought this was done by Episerver automatically when I do a Publish from code!?