Delete and Unpublish

ces55739's Avatar


04 Jun, 2015 06:26 PM


In Cascade's cms, there is an option to unpublish and delete. Looking through the web services options ( I am unable to find a usable function to unpublish and delete an asset. While searching, I see a "delete_unpublish" option, which looks promising. Again, I haven't had success in using it.

I would prefer not to unpublish and then delete, since the asset being unpublished might be in the queue for some time.

Any suggestions?

  1. 1 Posted by Wing Ming Chan on 04 Jun, 2015 07:06 PM

    Wing Ming Chan's Avatar


    I would say that the best option is to use triggers. But if you have to use web services, then this is my suggestion:

    1. Assuming that you have a way to identify the assets you want to delete, store the Id's in an array
    2. Schedule a cron job to unpublished the assets, using a web service script
    3, Schedule another cron job, maybe an hour later, to delete the assets, using another script

    These two scripts can be scheduled to run, for example, every day.


  2. 2 Posted by Ryan Griffith on 05 Jun, 2015 08:04 PM

    Ryan Griffith's Avatar


    I will need to verify this, but you might be able to call the delete operation and pass in a workflow configuration that points to an automated workflow which calls the deleteAndUnpublish trigger.

    I will follow up once I gather some additional information.


  3. 3 Posted by Wing Ming Chan on 22 Jun, 2015 06:26 PM

    Wing Ming Chan's Avatar


    This is what I did to unpublish and delete a page at the same time, using my library. First, I need to create a workflow definition using the UnpublishAndDelete trigger:

            $site_name = "_common";
            $wd_name   = "Unpublish and Delete";
            $parent = $cascade->getAsset( 
                a\WorkflowDefinitionContainer::TYPE, 'fd2770ba8b7f08560159f3f03223b508' );
            $xml = "<system-workflow-definition name='$wf_name' initial-step='initialize'>
    <trigger name='AssignStepIfUser' class='com.cms.workflow.function.AssignStepIfUser'/>
    <trigger name='AssignToGroupOwningAsset' class='com.cms.workflow.function.AssignToGroupOwningAsset'/>
    <trigger name='AssignToSpecifiedGroup' class='com.cms.workflow.function.AssignToSpecifiedGroup'/>
    <trigger name='AssignToWorkflowOwner' class='com.cms.workflow.function.AssignToWorkflowOwner'/>
    <trigger name='CopyFolder' class='com.cms.workflow.function.CopyFolder'/>
    <trigger name='com.cms.workflow.function.CreateNewWorkflowTrigger' class='com.cms.workflow.function.CreateNewWorkflowTrigger'/>
    <trigger name='Delete' class='com.cms.workflow.function.Delete'/>
    <trigger name='UnpublishAndDelete' class='com.cms.workflow.function.DeleteAndUnpublish'/>
    <trigger name='DeleteParentFolder' class='com.cms.workflow.function.DeleteParentFolderTrigger'/>
    <trigger name='Email' class='com.cms.workflow.function.EmailProvider'/>
    <trigger name='Merge' class='com.cms.workflow.function.Merge'/>
    <trigger name='PreserveCurrentUser' class='com.cms.workflow.function.PreserveCurrentUser'/>
    <trigger name='PublishContainingPublishSet' class='com.cms.workflow.function.PublishContainingPublishSetTrigger'/>
    <trigger name='PublishParentFolder' class='com.cms.workflow.function.PublishParentFolderTrigger'/>
    <trigger name='PublishSet' class='com.cms.workflow.function.PublishSetTrigger'/>
    <trigger name='Publish' class='com.cms.workflow.function.Publisher'/>
    <trigger name='Version' class='com.cms.workflow.function.Version'/>
    <trigger name='CreateNewWorkflow' class='com.cms.workflow.function.CreateNewWorkflowsTrigger'/>
    <step type='system' identifier='initialize' label='Initialization'>
    <action identifier='publish' label='Publish' move='forward' >
      <trigger name='UnpublishAndDelete' />
    <step type='system' identifier='finished' label='Finished'/>
            // create workflow definition
            $wd = 
                    a\WorkflowDefinition::NAMING_BEHAVIOR_AUTO, // naming behavior
                setCopy( false )->
                setCreate( false )->
                setDelete( true )->
                setEdit( false )->

    Secondly, with the workflow definition in place, I just need to edit the page in the following way:

            $page = $cascade->getAsset( 
                a\Page::TYPE, 'e7c936d78b7f085600b2e0be6a34e4ab' );
            $wd   = $cascade->getAsset( 
                a\WorkflowDefinition::TYPE, $wd_name, $site_name );
            $page->edit( NULL, $wd, $wd_name, "To be unpublished and deleted", false );
    The edit method is called here to associate a page with a workflow. This code works because the edit method defined in a\Page takes care of the workflow configuration when $wd is passed in. Workflow step configurations are bypassed though. The last argument, false, is passed in to skip processing of the structured data of the page, because right after the edit method is called, the page will be deleted, and there is no structured data to process. Without the false value, warnings will be issued.


  4. 4 Posted by ces55739 on 22 Jun, 2015 09:41 PM

    ces55739's Avatar

    Thank you Wing! Using the workflow you provided above worked for me.

  5. ces55739 closed this discussion on 22 Jun, 2015 09:41 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM