November Happy Hour will be moved to Thursday December 5th.

Copy and pasted pages always have published status

Vote:
 

When I copy and paste a page in the tree its status is always published or maybe it is the same of the page it is being copied from. I want to make the status of that page unpublished by default and then publish is manually later on. Is it possible?

#192212
May 10, 2018 20:52
Vote:
 

You could intercept IContentCopyHandler and pass in false for parameter "publishOnDestination" as:

 [ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
    public class CheckedOutCopyInitializableModule : IConfigurableModule
    {
        public void ConfigureContainer(ServiceConfigurationContext context)
        {
            context.Services.Intercept<IContentCopyHandler>((locator, defaultCopyHandler) => new CheckedOutContentCopyHandler(defaultCopyHandler));
        }

        public void Initialize(InitializationEngine context)
        {}

        public void Uninitialize(InitializationEngine context)
        {}
    }

    public class CheckedOutContentCopyHandler : IContentCopyHandler
    {
        private readonly IContentCopyHandler _defaultHandler;

        public CheckedOutContentCopyHandler(IContentCopyHandler defaultHandler)
        {
            _defaultHandler = defaultHandler;
        }

        public ContentReference Copy(ContentReference contentLink, ContentReference destinationLink, AccessLevel requiredSourceAccess, bool publishOnDestination)
        {
            return _defaultHandler.Copy(contentLink, destinationLink, requiredSourceAccess, false);
        }
    }
#192225
May 11, 2018 9:41
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.