AI OnAI Off
Yes, indeed. Even our old friend Alloy has the same issue.
Problem is with PageViewContextFactory and its CreateLayoutModel() method. Problem is that ContentLoader will give you back published version of the page and not one you are editing.
After this line:
var startPage = _contentLoader.Get<StartPage>(SiteDefinition.Current.StartPage);
Please add following lines to workaround this limitation:
if (requestContext.GetContextMode() == ContextMode.Edit) { var repo = ServiceLocator.Current.GetInstance<IContentVersionRepository>(); var link = repo.List(SiteDefinition.Current.StartPage).FirstOrDefault(v => v.Status == VersionStatus.CheckedOut); if (link != null) { startPage = _contentLoader.Get<StartPage>(link.ContentLink); } }
Within the last month, our product upgraded our website to version 8.5. Due to our product situation, our header and footer have been static partial views and not actually editable. Before the version upgrade, we were going to attempt to switch the footer to an editable one but the effort didn't fit into our sprint. I still went ahead and started playing around with how to develop it and I remember not running across this issue.
Any properties on the LayoutModel.cs and the StartPage.cs do not get visually updated when their value is updated (not published) from the All Properties or GUI views. I would make the update, go to preview the page, and no changes appeared to have been made. However, if I click into an editable field from the visual view, it suddenly populates. It always correctly shows the changed content in the All Properties view.
I have the Episerver VS extension so I created a new version 8.5 project with the MVC Alloy Sample site and I see the same issue. I tried recreating the issue by removing the links in the LinkItemCollection ProductPageLinks and publish. Then added an external link as an example (href for google) and then go to preview the page, seeing an empty area. The data change is recognized as changes needing to be published All Properties view.
The following are the snippets of code that should be correctly connecting the values between the two models and then displaying correctly on the view.
StartPage.cs
LayoutModel.cs
PageViewContextFactory.cs
StartPageController.cs
Footer.cshtml
I tried searching for this issue/solution but it appears that I'm the only one having it. Coworker expressed possible concern over server caching involved with PageContextActionFilter.