We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15083
    • 697 Posts
    I am using MODx for a site that may require email alerts to be sent out to subscribers when content changes are made to a page.

    Has anyone come across this before?

    An example might be whenever there is an edit made to a page using the manager, an email is sent to a group of web users upon saving.
    The user may for instance click a checkbox "Alert", if this is checked then the alert is sent when the document saves.

    Can anyone suggest how you might go about attempting something like this? I’m guessing you would need to hack into the modx events? No experience at all doing this so any help or pointers greatly appreciated smiley
      • 4385
      • 372 Posts
      I wrote a quick plugin to do a similar job. (more of a proof of concept)
      http://modxcms.com/forums/index.php/topic,36599.msg234676.html#msg234676

      Maybe you could use this in conjunction with a TV checkbox to allow notification for only those documents. As the plugin right now sends emails for every edit. Hope this is enough to get you started.
        DropboxUploader -- Upload files to a Dropbox account.
        DIG -- Dynamic Image Generator
        gus -- Google URL Shortener
        makeQR -- Uses google chart api to make QR codes.
        MODxTweeter -- Update your twitter status on publish.
        • 15083
        • 697 Posts
        Thanks man, that looks like a definite starting point.
        In OnDocFormSave, can I access the $_POST vars that would be present on the page?

        If I was to add a checkbox as a TV, would I be able to access it via $_POST[’mytvname’];
        If so then this is exactly what I want. I can pull the relevant users from the DB and send a mail out to each of them.
          • 4385
          • 372 Posts
          Create a TV called "alert" with input options ’on==1||off==0’ and default to 0

          Create a plugin with this code.

          	$to = "[email protected]";
          	$subject = " documents";
          	$message = "The latest edits.\r\n";
          	$headers = 'From: [email protected]' . "\r\n";
          
          $alertTV = $modx->getTemplateVar('alert', "", $id);
          if ($alertTV['value'] ==  1) {
          
          $docLink =  $modx->makeUrl($id,"", "", "full");
          if ($mode ==  "upd") {
          $activity = "Update";
          }else{
          $activity = "New";
          }
          $subject = $activity . $subject;
          mail($to, $subject, $message . $docLink, $headers);
          $modx->sendAlert('alert',1,1,$subject,$message . $docLink,1);
          }
          


          check off OnDocFormSave for System Events.
            DropboxUploader -- Upload files to a Dropbox account.
            DIG -- Dynamic Image Generator
            gus -- Google URL Shortener
            makeQR -- Uses google chart api to make QR codes.
            MODxTweeter -- Update your twitter status on publish.
            • 15083
            • 697 Posts
            TY v much. That is great
            grin
              • 4385
              • 372 Posts
              You can take out the admin messages, I was using it to test the results on my MAMP setup.
              $modx->sendAlert('alert',1,1,$subject,$message . $docLink,1);
                DropboxUploader -- Upload files to a Dropbox account.
                DIG -- Dynamic Image Generator
                gus -- Google URL Shortener
                makeQR -- Uses google chart api to make QR codes.
                MODxTweeter -- Update your twitter status on publish.
                • 15083
                • 697 Posts
                have it working on a test site...thanks a lot for the help, easier than I though it would be.