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?
IPublishedContent
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.
IContent
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.
https://our.umbraco.com/apidocs/v7/csharp/api/Umbraco.Core.Services.IContentService.html#UmbracoCoreServicesIContentServiceSaveSystemCollectionsGenericIEnumerableUmbracoCoreModelsIContent_SystemInt32SystemBoolean_
I'm using Umbraco 8.5.4. So what you are suggesting is basically what I mentioned in my previous post?
Hi Johan.
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.
Regards Malthe
Hi Malthe,
Excellent, exactly what I was looking for, thanks!
Hello Malthe,
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)
Hey
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:
Upload image
Image will be uploaded when post is submitted
Get unpublished page as IPublishedContent
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 toIPublishedContent
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.
https://our.umbraco.com/apidocs/v7/csharp/api/Umbraco.Core.Services.IContentService.html#UmbracoCoreServicesIContentServiceSaveSystemCollectionsGenericIEnumerableUmbracoCoreModelsIContent_SystemInt32SystemBoolean_
I'm using Umbraco 8.5.4. So what you are suggesting is basically what I mentioned in my previous post?
Hi Johan.
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.
Regards Malthe
Hi Malthe,
Excellent, exactly what I was looking for, thanks!
Hello Malthe,
Tried using it on Umbraco v7 - UmbracoContext.ContentCache.GetById(true, Id); but it's giving me an error.
Hey
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...