We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15362
    • 22 Posts
    Hello modxers!!

    I need your help.

    I am using Articles for my blog.

    When i am writing new article unpublished is default.

    Is there any way to make published default?

    Thanks
      • 21739
      • 49 Posts
      In the System Setting, search for "publish_default" and set that to "Yes".
      Note that this applies to all your resources.
        • 27708 MODX Staff
        • 2,502 Posts
        There is a system setting that should make all Resources, including Articles Resources, 'Published' by default. This should work. Another possible method would be to write plugin that sets all Resources to Published on save.
          Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
          • 15362
          • 22 Posts
          Seems that publish_default is not working for articles.

          Only for documents weblinks etc
            • 27708 MODX Staff
            • 2,502 Posts
            This will require a plugin that sets the state to published if the document is a child of the articles container onBeforeFormSave.
              Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
              • 15362
              • 22 Posts
              Thanks Jay, i will try this!!!

              Cheers

                • 3749
                • 24,544 Posts
                Looking at the Articles code, it appears to save a single new resource directly without invoking any events or calling any MODX processors (though I don't have the current version installed, so that may have changed).

                That would explain why the System Setting has no effect.

                IIRC, there used to be a System Setting OnSaveResource or OnResourceSave that you could connect a plugin to, but I don't find it any more (if it ever existed) so there may be no way to solve this without hacking the Articles code.

                Changing this line in the articles.class.php file:

                 if (!$newResource->save()) {


                to this:

                $this->set('published', true);
                if (!$newResource->save()) {
                


                would certainly do it.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting