We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3109 ☆ A M B ☆
    • 894 Posts
    So I got Resourcewatcher and Newspublisher working which is great (Romain and Bob have done a great job with these extras) now I want to be able to create a new resource via Newspublisher and have that trigger Resourcewatcher so it can notify me that a new resource was created.

    I just need them to talk to each other any ideas let me know.

    Thanks. [ed. note: benmarte last edited this post 14 years, 10 months ago.]
      Benjamin Marte
      Interactive Media Developer
      Follow Me on Twitter | Visit my site | Learn MODX
      • 33976 ☆ A M B ☆
      • 571 Posts
      Ben,

      After our talk yesterday, i guess the solutions available would be :


      • - Invoke the appropriate events in NewsPublisher
      • - Make use of runProcessor in NewsPublisher (which might not be trivial)

      I'm pretty sure Bob will come up with other ideas smiley
        • 3109 ☆ A M B ☆
        • 894 Posts
        Romain,

        We are trying to invoke the OnDocFormSave event when NewsPublisher successfully saves a resource but we are having no luck yet.

        Thanks again for fixing ResourceWatcher yesterday and taking the time to answer smiley
          Benjamin Marte
          Interactive Media Developer
          Follow Me on Twitter | Visit my site | Learn MODX
          • 3749
          • 24,544 Posts
          Ben,

          NewsPublisher already calls the MODX resource create and update processors to save resources. Both OnDocFormSave and OnBeforeDocFormSave are invoked in both processors.


            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
            • 3109 ☆ A M B ☆
            • 894 Posts
            @BobRay It's weird because Newspublisher creates the resource and works great, ResourceWatcher works great as long as I create the resource on the manager side.

            I just thought since ResourceWatcher notifies of any new resources created it would automatically trigger when NewsPublisher created a resource.

            Any suggestions on what I can try?

            Thanks guys.
              Benjamin Marte
              Interactive Media Developer
              Follow Me on Twitter | Visit my site | Learn MODX
              • 3749
              • 24,544 Posts
              Could it be because the resource create and update processors never fire OnDocPublished?
                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
                • 33976 ☆ A M B ☆
                • 571 Posts
                Ben,

                After stepping back and thinking about your issue, i just though that you might want to edit the ResourceWatcher plugin :
                if ($modx->context->get('key') != 'mgr') return;

                This is more than probably the culprit smiley
                  • 3109 ☆ A M B ☆
                  • 894 Posts
                  @romain I will test this out tomorrow and let you know if it works, once again thank you both smiley
                    Benjamin Marte
                    Interactive Media Developer
                    Follow Me on Twitter | Visit my site | Learn MODX
                    • 3109 ☆ A M B ☆
                    • 894 Posts
                    @romain I commented out that line in the plugin and it works now.

                    Also had to change line 166 in resourcewatcher.class.php located in: core/components/resourcewatcher/model/resourcewatcher from this:

                    $phs = array_merge($resource->toArray(),$user->toArray(), $profile->toArray(),$id); $this->modx->setPlaceholders($phs, $prefix);
                    


                    to this:

                    $phs = array_merge(
                    	  //$resource->toArray(),
                    	  $user->toArray(),
                    	  $profile->toArray(),
                    	  $id);
                            $this->modx->setPlaceholders($phs, $prefix);
                    


                    That got it working on both front end and back end.

                    Then I added this to get it working only for a specific user group since I don't want it emailing me every time someone creates or edits something on the backend.
                    if (!$modx->user->isMember('Blogger')) return;
                    


                    On line 4 of the ResourceWatcher plugin in case someone wanted to run this on a specific user group.

                    @romain I hope this helps you to accomplish what you wanted to do with ResourceWatcher when we spoke on IRC.

                    Thanks for your help guys.
                      Benjamin Marte
                      Interactive Media Developer
                      Follow Me on Twitter | Visit my site | Learn MODX