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. I'm trying to execute an action from the ModelsBuider only when a node (document) is published and not having execute when the Editor Unpublishes it. When I check the status I always get that IsDraft() is false.
How can I check if the node is been set in Draft.
Thanks
Further on... this is dummy code I'm testing trying to figure out what's wrong:
private static void ExecWhenUnpublished(IPublishedContent node) { // write only visible nodes bool published = node.IsPublished(); //always true bool drafted = node.IsDraft(); //always false even if node is Draft bool visible = node.IsVisible(); //always true even if node is Draft if (published && drafted == false && visible) { // whatever } } } public class SubscribeToUnpublishedEventComponent : IComponent { /// <summary> /// Initialize: runs once when Umbraco starts /// </summary> public void Initialize() { ContentService.Unpublished += ContentService_Unpublished; } /// <summary> /// Terminate: runs once when Umbraco stops /// </summary> public void Terminate() { ContentService.Unpublished -= ContentService_Unpublished; } /// <summary> /// Write sitemap.xml in Media\_sitemap /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ContentService_Unpublished(IContentService sender, PublishEventArgs<IContent> e) { // whatever } }
Any help areciated
Found a workaround without checking the node status. Issue not solved but closed for me.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
node.IsDraft() is always False
Hi. I'm trying to execute an action from the ModelsBuider only when a node (document) is published and not having execute when the Editor Unpublishes it. When I check the status I always get that IsDraft() is false.
How can I check if the node is been set in Draft.
Thanks
Further on... this is dummy code I'm testing trying to figure out what's wrong:
Any help areciated
Found a workaround without checking the node status. Issue not solved but closed for me.
is working on a reply...