More in this section

Forums / Developing with Sitefinity / Is there a way to unpublish a page

Is there a way to unpublish a page

16 posts, 0 answered
  1. jcrichto
    jcrichto avatar
    35 posts
    Registered:
    14 Aug 2012
    28 Jan 2009
    Link to this post
    I am not seeing a way to demote (or unplublish) a page once it has been published without deleting it.  Is there something I am missing.  I have workflows enabled.

    Thanks,

    - Jeremy
  2. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    28 Jan 2009
    Link to this post
    I believe you can set "Show in Navigation" to "No".  You can also set "Anonymous Access" to "Deny".  Lastly, you could also change the "Page name" to change the URL and break old links.

    In most cases setting "Show in Navigation" to "No" will be enough to hide the page.  The other steps prevent direct access.

    Gabe Sumner
    http://www.sitefinitywatch.com/
  3. Jason M
    Jason M avatar
    108 posts
    Registered:
    15 Jan 2007
    28 Jan 2009
    Link to this post
    You can also use the "History" tab and "Roll Back" to an older version --> providing you have a previously published version.

    J
  4. jcrichto
    jcrichto avatar
    35 posts
    Registered:
    14 Aug 2012
    28 Jan 2009
    Link to this post
    Thanks Gabe.

    Not ideal, but I guess turning off show in navigation and breaking the link could work in most cases.  But what a nasty hack!  Is a simple method to manually change the workflow state of a page in the CP too much to expect?

    - Jeremy
  5. jcrichto
    jcrichto avatar
    35 posts
    Registered:
    14 Aug 2012
    28 Jan 2009
    Link to this post
    Thanks Jason, but I am not wanting to rollback to a previously "published" version, I want to "unpublish" my page, thus taking it back out of the site completely, but letting admins still see it and edit, etc, and later republish.

  6. UI Crew
    UI Crew avatar
    99 posts
    Registered:
    24 Sep 2012
    28 Jan 2009
    Link to this post
    Hi Jeremy,

    As there is no unpublished state in Sitefinity unfortunately, I have found the best method for my clients is to create a page at the lowest level called "Archived" or "Trash" and set this page's "Show in Navigation" state to no and it's "deny anonymous access" state to "yes".

    That way you can drag pages you want to unpublish into this group and the page will not appear in navigation and will also temporarily inherit the "Archived" page's deny state.

    Then when it's good to go drag it back out into the right place again.

    I also encourage content managers to use this method before deleting a page and leave it in the trash for a couple of weeks before deleting it just in case.

    Hope that helps.

    Thaks

    Seth 
  7. UI Crew
    UI Crew avatar
    99 posts
    Registered:
    24 Sep 2012
    28 Jan 2009
    Link to this post
    Hi Jeremy,

    As there is no unpublished state in Sitefinity unfortunately, I have found the best method for my clients is to create a page at the lowest level called "Archived" or "Trash" and set this page's "Show in Navigation" state to no and it's "deny anonymous access" state to "yes".

    That way you can drag pages you want to unpublish into this group and the page will not appear in navigation and will also temporarily inherit the "Archived" page's deny state.

    Then when it's good to go drag it back out into the right place again.

    I also encourage content managers to use this method before deleting a page and leave it in the trash for a couple of weeks before deleting it just in case.

    Hope that helps.

    Thanks

    Seth 
  8. jcrichto
    jcrichto avatar
    35 posts
    Registered:
    14 Aug 2012
    28 Jan 2009
    Link to this post
    Hi Seth,

    We actually had thought of that method, and it is not bad except that it is still possible to find the trash pages at their url "/trash/mypage.aspx" in the public space unless you change the permissions of each page you move to this location.   I realize not many people would look here, but the fact is, my trash is available to the public. 

    Also, the anonymous option isn't very helpful because we have logins for users...thus they are not anonymous.

    - Jeremy
  9. UI Crew
    UI Crew avatar
    99 posts
    Registered:
    24 Sep 2012
    28 Jan 2009
    Link to this post
    Hi,

    If you didn't allow any of your authenticated public users to view pages under /trash.aspx (by setting the view permissions of that page to deny as well as "deny anonymous access") then they shouldn't be able to come across them and shouldn't be able to access even if typing in the url.

    In theory...

    Seth
  10. UI Crew
    UI Crew avatar
    99 posts
    Registered:
    24 Sep 2012
    28 Jan 2009
    Link to this post
    Hi,

    If you didn't allow any of your authenticated public users to view pages under /trash.aspx (by setting the view permissions of that page to deny as well as "deny anonymous access") then they shouldn't be able to come across them and shouldn't be able to access even if typing in the url.

    In theory...

    Seth
  11. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    28 Jan 2009
    Link to this post
    To be honest, I agree with you, all of these recommendations feel hacky to me too.  There should probably be a "Visible" or "Published" Sitefinity page property that we can toggle.  I'll toss this suggestion to the team and see what they say. 

    In the meantime, here is another hacky solution.  Just create a custom user control called "404" or "NothingToSeeHere" and use the following code:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["cmspagemode"] != "edit") {
            Response.Clear();
            Response.StatusCode = 404;
            Response.End();
        }
    }

    Drag this control onto your Sitefinity page and direct links and this page will be generate a 404 (even if visited directly).  This is hacky but it will work.

    Gabe Sumner
    http://www.sitefinitywatch.com/
  12. UI Crew
    UI Crew avatar
    99 posts
    Registered:
    24 Sep 2012
    28 Jan 2009
    Link to this post
    Hi,

    On the "All pages" page in admin, ~/Sitefinity/Admin/Pages.aspx, which lists all page states there is an "Archived" page state just to the right of "Published" 

    I remember asking about that oh years ago now and got the response that it was planned but no fully implemented - oh look back in 2007 I found it:

    http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-baabem.aspx

    Seth
  13. jcrichto
    jcrichto avatar
    35 posts
    Registered:
    14 Aug 2012
    29 Jan 2009
    Link to this post
    Thanks for your support on this guys...
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    29 Jan 2009
    Link to this post
    Hi Jeremy and Gabe, Seth

    Here is my way to unpublish the page when workfolow is enabled. I am setting the page to another status of the workflow.

               CmsManager cmsManager = new CmsManager();  
            CmsSiteMapNode nodeForEdit = (CmsSiteMapNode)SiteMap.Provider.FindSiteMapNode("~/Test2.aspx");  
            ICmsPage pageForEdit = cmsManager.GetPage(nodeForEdit.CmsPage.ID, trueas ICmsPage;  
              
            // checkIn and CheckOut the page creating a new version of the page.  
            IStagedPage staged = pageForEdit.Staged.CheckOut();  
            staged.CheckIn();  
      
            pageForEdit = (ICmsPage)cmsManager.GetPage(nodeForEdit.CmsPage.ID, true);  
            //On each step we should clear the Nolics cache...   
            ExecuteActivity(pageForEdit.WorkflowID, "SendForApproval");  
            Nolics.ORMapper.Base.DataConnection.InitWebRequest();   
       
        private EventActivity FindActivity(string name, IList<Activity> activities)  
        {  
            foreach (Activity act in activities)  
            {  
                if ((act is EventActivity) && (((EventActivity)act).CommandName == name))  
                    return (EventActivity)act;  
                EventActivity ea = FindActivity(name, act.Activities);  
                if (ea != null)  
                    return ea;  
            }  
            return null;  
        }  
      
        private void ExecuteActivity(Guid pageId, string activityName)  
        {  
            WorkflowInstance instance = WorkflowRuntime.Instance.GetWorkflow(pageId);  
            if (instance != null)  
            {  
                PageWorkflow workflow = (PageWorkflow)instance.Activity;  
                EventActivity activity = FindActivity(activityName, workflow.Activities);  
                if (activity != null)  
                {  
                    activity.Execute(WorkflowRuntime.Instance);  
                }  
            }  
        }   

    Additionally the page could be hidden if you set pageForEdit.Navigable = false;

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  15. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    28 Oct 2009
    Link to this post
    Hi Jeremy
    Did you get this working after?

    we are using 3.6 and are trying to get this extra item in the workflow process

    we want the activity cycle to push the publish/unpubilsh code in our custom page workflow, what is the code we need to use to acheive this?

    thanks
  16. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    28 Oct 2009
    Link to this post
    Hi Quade,

    Please take at the following post which describes how to create a custom workflow. Then you need to use the suggestion from my previous post.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
16 posts, 0 answered