We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23849
    • 223 Posts
    Can anyone tell me what php I might need to change to set duplicate documents as "published" by default (rather than un-published). Let me know, thanks!
      Nick Hoag
      Creative Partner
      The FutureForward

      http://thefutureforward.com
      • 33337
      • 3,975 Posts
      I think there is a setting in the site config for that. Please see Tools -> Configuation -> Site, look for Published by default (or similar option).

      Hope this helps.
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 23849
        • 223 Posts
        Hi zi,

        That setting works when creating new documents, but when duplicating documents modx still sets the new, duplicated document to un-published. I think it will require a PHP change.. just not sure where that is!
          Nick Hoag
          Creative Partner
          The FutureForward

          http://thefutureforward.com
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Check the manager/processors/duplicate_content.processor.php file, around line 68 you’ll find:
          	// [FS#922] Should the published status be honored? - sirlancelot
          //	if ($modx->hasPermission('publish_document')) {
          //		if ($modx->config['publish_default'])
          //			$content['pub_date'] = $content['pub_date']; // should this be changed to 1?
          //		else	$content['pub_date'] = 0;
          //	} else {
          		// User can't publish documents
          //		$content['published'] = $content['pub_date'] = 0;
          //	}
          
              // Set the published status to unpublished by default (see above ... commit #3388)
              $content['published'] = $content['pub_date'] = 0;
          

          It was turning out to be an incredible can of worms to try to determine if the duplicate should be published or not. But you can change that if you want; just keep your changes in mind (and a copy of it somewhere) for when you want to upgrade your MODx installation.

          Unfortunately the processor doesn’t call any of the document events, or it could be accomplished with a plugin instead of hacking the core. sad
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 23849
            • 223 Posts
            Awesome, Thanks Susan!!
              Nick Hoag
              Creative Partner
              The FutureForward

              http://thefutureforward.com