We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8168
    • 1,118 Posts
    Hey Bob - thanks for this, this snippet code no longer hangs the save process - but does not fire an email... In the error log I have:

    [2013-06-26 09:45:01] (ERROR @ /connectors/resource/index.php) editedby is empty


    Any ideas?
      • 3749
      • 24,544 Posts
      Ah. The editedby field is empty if a new resource is created, but never edited.

      Try this:

      $editor = $resource->get('editedby');
      if (empty($editor)) {
          $editor = $resource->get('createdby');
      }


      or you could just go with createdby to begin with:

      $editor = $resource->get('createdby');
        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
        • 8168
        • 1,118 Posts
        Quote from: BobRay at Jun 26, 2013, 05:40 AM
        Ah. The editedby field is empty if a new resource is created, but never edited.

        Try this:

        $editor = $resource->get('editedby');
        if (empty($editor)) {
            $editor = $resource->get('createdby');
        }


        or you could just go with createdby to begin with:

        $editor = $resource->get('createdby');

        Thanks Bob - Saving works, no hanging, nothing in error logs... but no email sent... Something in the hook preventing the email from being sent for some reason... if I remove the hook snippet code then it will send a mail... odd...? Any ideas?

        UPDATE... does work actually... darn typo when setting the $editor var in the snippet! I will have a play and let you know how it all works...
          • 8168
          • 1,118 Posts
          Quote from: dubbs at Jun 26, 2013, 06:22 AM
          Quote from: BobRay at Jun 26, 2013, 05:40 AM
          Ah. The editedby field is empty if a new resource is created, but never edited.

          Try this:

          $editor = $resource->get('editedby');
          if (empty($editor)) {
              $editor = $resource->get('createdby');
          }


          or you could just go with createdby to begin with:

          $editor = $resource->get('createdby');

          Thanks Bob - Saving works, no hanging, nothing in error logs... but no email sent... Something in the hook preventing the email from being sent for some reason... if I remove the hook snippet code then it will send a mail... odd...? Any ideas?

          UPDATE... does work actually... darn typo when setting the $editor var in the snippet! I will have a play and let you know how it all works...

          Tis working nicely now Bob - thanks for your guidance here!

          The only short coming of this implementation comes when an editor edits a live resource... when they save, the amends go directly live... the Publisher does receive an email notifying them of the update - but the editor's changes go live upon saving the resource... is there a way to prevent this? The implementation works perfect for NEW resources - but not updating existing ones...
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            I started playing around with the Stagecoach extra a while ago, and it seems pretty interesting. http://bobsguides.com/stagecoach-tutorial.html
              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
              • 8168
              • 1,118 Posts
              Quote from: sottwell at Jun 26, 2013, 09:32 AM
              I started playing around with the Stagecoach extra a while ago, and it seems pretty interesting. http://bobsguides.com/stagecoach-tutorial.html

              Thanks Susa, having looked at http://modx.com/extras/package/stagecoach I am not sure this would fulfill the criteria I had set out though - this seems like a tool to allow the resource to be updated but not pushed live until a picked date/time - what I would need is the ability for a MODx user to update a resource and then flag it for approval before the updates they had made were pushed live. I guess one could make the editor set the StageCoach publish date for a year in the future, then upon save, the publisher would get an email notifying them the editor had updated the resource - they could then login, review and then publish the resource when ready... Would kinda work I guess... The main downside being that the editor has to set the StageCoach publish date rather than just hitting - save...
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Maybe Bob can be coaxed into adding features wink
                  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
                  • 8168
                  • 1,118 Posts
                  Quote from: sottwell at Jun 26, 2013, 10:47 AM
                  Maybe Bob can be coaxed into adding features wink

                  That would be awesome... eh Bob! smiley

                  If this was packaged with the http://www.bdcreative-design.com/blog/my-solution-for-a-resource-approval-workflow-using-modx.html solution and ResourceWatcher then a staged workflow solution with hierarchy notifications could be added to a MODx site - a very powerful addon I think!
                    • 3749
                    • 24,544 Posts
                    Quote from: dubbs at Jun 26, 2013, 06:38 AM

                    The only short coming of this implementation comes when an editor edits a live resource... when they save, the amends go directly live... the Publisher does receive an email notifying them of the update - but the editor's changes go live upon saving the resource... is there a way to prevent this? The implementation works perfect for NEW resources - but not updating existing ones...


                    On the properties tab when editing the ResourceWatcher plugin, if you set these properties to true, it should work on both new and updated resources:


                    &resourcewatcher.new_active
                    &resourcewatcher.upd_active
                      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
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Of course a plugin can be used to send email when a resource is created or edited.
                        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