Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Stueve 30 posts 49 karma points
    Oct 18, 2010 @ 21:29
    Matt Stueve
    0

    Publish at and Remove at Dates Question

    I'm running a site on Umbraco 4.0.4.2 and have tested the Publish at and Remove at dates.  I created a new page, entered a publish at date of a couple hours later, and saved (didn't publish).  When I came back into Umbraco after the publish at date had passed, the item showed as published, but still threw a 404 error.  When I right-clicked on the content node and did a "republish entire site," then the page worked fine.

    So, it looks like it published in terms of status, but didn't really publish in that it didn't update umbraco.config?  Am I doing this incorrectly?

    Thanks,
    Matt

  • Erik 1 post 21 karma points
    Oct 24, 2010 @ 20:17
    Erik
    0

    I am almost facing the same problem, running Umbraco 4.0.4.2.

    It seems to me that the published flag is still set to Published = true.
    When the the document gets automatically unpublished is it unpublished using umbraco.library.UnPublishSingleNode?
    If so, why?

    To solve this problem I created an AutoUnPublishHandler

    This will run every time a document is automatically unpublished. But I am not sure if this is the right way to solve the problem.

    public class AutoUnPublishHandler : umbraco.BusinessLogic.Actions.IActionHandler
    {

     

    public bool Execute(umbraco.cms.businesslogic.web.Document documentObject, umbraco.interfaces.IAction action)
    {

    if (action.Alias == umbraco.BusinessLogic.Actions.ActionUnPublish.Instance.Alias)
    {

    // When the document is automatically unpublished the published flag will still be set to true.
    if (documentObject.Published)
    {

    //Run unpublish on the document so that the published flag is set to false.
    documentObject.UnPublish();

    // Tell the published XML content that the document has been unpublished.
    umbraco.library.RefreshContent();
    }
    }
    }

     

     

    public string HandlerName()
    {
                return "AutoUnPublishHandler";
    }

            public umbraco.interfaces.IAction[] ReturnActions()
            {
                return new umbraco.interfaces.IAction[] { umbraco.BusinessLogic.Actions.ActionUnPublish.Instance };
            }
    }

     

  • Matt Stueve 30 posts 49 karma points
    Nov 23, 2010 @ 23:40
    Matt Stueve
    0

    It looks like the issue might be that umbraco.library.RefreshContent() isn't called when the scheduler auto publishes or unpublishes?  Is this a confirmed issue or am I doing something incorrectly? (I haven't looked at the source code for 4.0.4.2 to confirm/deny this).  Erik, has the above code solved your problems?  I think I'd need to create a similar handler for auto publish as well as unpublish?

    Thanks,
    Matt

Please Sign in or register to post replies

Write your reply to:

Draft