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
I have a page that has never been published. How can I fetch this particular page as IPublishedContent using your services?
I know that I can fetch it as IContent, but as far as I can tell, there is no way to convert it to IPublishedContent in Umbraco 8.
You just need to save the node, using the ICONTENT.
It will then make that node available via IPublishedContent, as it will appear in the cache.
Thanks for the response. You mean save and publish, right? In this case, I don't want to show the page to the users yet.
I guess I have to perform a SaveAndPublish > Unpublish? Or is there a better way?
Depending on what particular version of Umbraco you are using, there's several overrides on the "save" event.
I'm using Umbraco 8.5.4. So what you are suggesting is basically what I mentioned in my previous post?
You can get the preview content from the cache by using UmbracoContext.Content.GetById(true, Id).
The “true” is you telling that you would like to get the saved, not yet published, version of the content.
Hope this helps.
Excellent, exactly what I was looking for, thanks!
Tried using it on Umbraco v7 - UmbracoContext.ContentCache.GetById(true, Id); but it's giving me an error.
at umbraco.presentation.preview.PreviewContent.EnsureInitiaenter code herelized(User user, String previewSet, Boolean validate, Action initialize)
I am not sure how it is done in v7, or even if it is possible, but the above works in v8.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted