Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
is it possible to generate a full page with HTML markup using a Page Version GUID?
Something like var htmlOfPage = Umbraco.RenderTemplate(pageId); but using the version GUID so I can see a full front end page of a previous version.
Thanks
Jon
Hi Jon
You can use the ContentService to retrieve an IContent item representing a specific version of the content, from the database
var cs = Services.ContentService; var specificVersion = cs.GetByVersion(Guid versionId);
However your existing views will likely be working with IPublishedContent, rather than IContent.
Jeroen Breuer wrote an article about converting IContent to IPublishedContent for edge cases...
https://24days.in/umbraco-cms/2016/umbraco-edge-case-stories/#convert
He's created an extension method called ToPublishedContent() in this gist
https://gist.github.com/jbreuer/dde3605035179c34b7287850c45cb8c9
so after retrieving your specific version using the content service, you could probably use this trick to turn it into IPublishedContent and work with your existing templates to generate a view of what the content looked like in the earlier version.
regards
Marc
Thanks a lot for this.
Is it then possible to create a HTML webpage from IPublishedContent.
For example, should I call the function that I create IPublishedContent via JQuery or someway else?
The render of the page needs to be dynamic so I cant pre code the page layout.
The RENDERTEMPLATE result is ideally the return that I desire but instead of passing in the PageId I would pass in the Version GUID.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Render page as HTML using a Page Version GUID
Hi,
is it possible to generate a full page with HTML markup using a Page Version GUID?
Something like var htmlOfPage = Umbraco.RenderTemplate(pageId); but using the version GUID so I can see a full front end page of a previous version.
Thanks
Jon
Hi Jon
You can use the ContentService to retrieve an IContent item representing a specific version of the content, from the database
However your existing views will likely be working with IPublishedContent, rather than IContent.
Jeroen Breuer wrote an article about converting IContent to IPublishedContent for edge cases...
https://24days.in/umbraco-cms/2016/umbraco-edge-case-stories/#convert
He's created an extension method called ToPublishedContent() in this gist
https://gist.github.com/jbreuer/dde3605035179c34b7287850c45cb8c9
so after retrieving your specific version using the content service, you could probably use this trick to turn it into IPublishedContent and work with your existing templates to generate a view of what the content looked like in the earlier version.
regards
Marc
Thanks a lot for this.
Is it then possible to create a HTML webpage from IPublishedContent.
For example, should I call the function that I create IPublishedContent via JQuery or someway else?
The render of the page needs to be dynamic so I cant pre code the page layout.
The RENDERTEMPLATE result is ideally the return that I desire but instead of passing in the PageId I would pass in the Version GUID.
Jon
is working on a reply...