Show a specific version of a sharepoint publish page instead of the most recent approved version to anonymous users

I am trying to create a control that will provide anonymous users with any particular version of the sharepoint publishing page. Example:

MyPage.aspx has versions 1.0, 2.0, 3.0, 4.0, with 4.0 being the latest published version. Sharepoint by default delivers version 4.0 to anonymous users. I want to be able to programmatically provide them with version 2.0. I know how to check anonymous users and get an object for the version of the page I want. My question is: how can I tell sharepoint to deliver the specified page object?

Below I still work ...

PublishingPage currentPage = GetCurrentPageObjectVersion(2); if (currentPage != null) { // Tell sharepoint to deliver currentPage somehow? } private SPFileVersion GetCurrentPageObjectVersion(int requestedVersion) { SPFileVersion specifiedVersion = null; try { PublishingPage currentPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem); specifiedVersion = currentPage.ListItem.File.Versions.GetVersionFromID(requestedVersion); } catch (Exception e) { // Error handling here } return specifiedVersion; } 

Any help would be very helpful! Please let me know if you need any clarification!

+4
source share
1 answer

From your SPFileVersion you can get the list item associated with a specific version of the page. Then your control can set (override) the values โ€‹โ€‹of the controls on the page (determined by the page layout) using the property values โ€‹โ€‹of the version list element.

0
source

Source: https://habr.com/ru/post/1391322/


All Articles