We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47047
    • 43 Posts
    Hi, I want to use MessageManager snippet for web users. I'm following the tutorial but I can't see other options for send a new message.

    I have this on my resource

    [[!MessageManager?  &recipient_options=`user,usergroup,all` &allowed_groups=`user`]]


    This is what my message-manager resource shows:

    http://prntscr.com/jxd69s

    Thanks for your help.

    This question has been answered by BobRay. See the first response.

      @yulianita
      • 3749
      • 24,544 Posts
      Try right-clicking on the grid.

      FYI, I saw a message from a core developer suggesting that the message system might be removed in an upcoming version of MODX, in which case MessageManager would be DOA.
        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
        • 47047
        • 43 Posts
        Quote from: BobRay at Jun 21, 2018, 06:02 AM
        Try right-clicking on the grid.

        FYI, I saw a message from a core developer suggesting that the message system might be removed in an upcoming version of MODX, in which case MessageManager would be DOA.


        I tried with right-clicking but didn't work, but now I think I'm going to remove it because it's not worth it if in a couple of MODX versions will not work and I'm sorry because I think it's a great feature. Do you know some other extra that you can recommend me?. Thank you BobRay, your help is very valuable.
          @yulianita
          • 3749
          • 24,544 Posts
          Thanks for the kind words.
          I don't know that it will be removed. I just wanted to let you know that it's a possibility. I don't know of another extra you could use, but there may be one.

          Do you actually have a group called 'users'? That property has to be a real group and the person using MM has to be a member of that group *and* explicitly log in in the front end.

          Try leaving out the &allowed_groups property from the snippet tag (and make sure the default property of the snippet is empty).

            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
            • 47047
            • 43 Posts
            Yes BobRay, I have a group called "users" in the policy "context". I added message permission to this context template, I removed allowed_groups property from the snippet tag. I did a test sending a message from an admin user to this web user, the message is there but I can't read it or remove, and still can't see other options like "write new message" right-clicking in the grid.

            This is what it shows "message-manager" resource logged in the web user account.http://prntscr.com/jy4ntb

            I will be positive and I will trust the possibility that this extra will not be removed in the future wink
              @yulianita
            • discuss.answer
              • 3749
              • 24,544 Posts
              Are you a member of the 'users' group?

              It sounds like you might have a JavaScript conflict, a CSS rule that is hiding some things, or a corrupted file in MessageManager.

              View the page in Chrome and turn on Dev. Tools (Ctrl-shift-i). Look at the Console tab for any JS errors.
              Look at the Network tab and reload the page to see if there are any 404 errors.

              If that doesn't show anything, click on the inspect button at the far left of the Dev. Tools toolbar, then click on the Message Manager grid. You can click on different lines in the code at the left and look for any CSS issues in the window to the right of the Dev. Tools grid.



                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
                • 47047
                • 43 Posts
                Quote from: BobRay at Jun 22, 2018, 07:07 PM
                Are you a member of the 'users' group?

                It sounds like you might have a JavaScript conflict, a CSS rule that is hiding some things, or a corrupted file in MessageManager.

                View the page in Chrome and turn on Dev. Tools (Ctrl-shift-i). Look at the Console tab for any JS errors.
                Look at the Network tab and reload the page to see if there are any 404 errors.

                If that doesn't show anything, click on the inspect button at the far left of the Dev. Tools toolbar, then click on the Message Manager grid. You can click on different lines in the code at the left and look for any CSS issues in the window to the right of the Dev. Tools grid.




                Of course your right, I have a conflict with jquery files, I do not know why I did not check before. (¬_¬)
                thanks for your help I really appreciate it and your useful Extra! I will make a donation soon smiley
                  @yulianita
                  • 3749
                  • 24,544 Posts
                  Thanks! I'm glad you got it sorted. smiley

                  Can you tell me where the conflict occurred?
                    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
                    • 47047
                    • 43 Posts
                    Quote from: BobRay at Jun 22, 2018, 10:10 PM
                    Thanks! I'm glad you got it sorted. smiley

                    Can you tell me where the conflict occurred?


                    I had this link of jquery library in my template (jquery-2.2.0.min.js) which creates conflict with the jquery version of MessageManager (https://ajax.googleapis.com/ajax/libs/jquery/1.12.1/jquery.min.js) so, now I have a different template for that resource in which I do not need my version of jquery.

                    Please one more question, in my case... in the web context, users can see the profiles of other users, the idea is that in the profile of each user there will be a button to "write message". Is there a way for those who visit the profile to leave a message to the user? maybe calling the "new message" option, but how?

                    Surely there is a way but I need a light to follow, thanks in advance.
                      @yulianita
                      • 3749
                      • 24,544 Posts
                      MM is pretty much tied to the message grid, so there's no easy way to use it directly.

                      You could use the mm-ajax resource to send the messages, though.

                      I think what I would do would be to create a popup message form that is hidden until you click on the "Send Message to User" button (which would be outside a form and not a real submission button). You need to set the html_file_extension placeholder (or just hard-code it to whatever your site uses for that content type).

                      The popup form would have its own submit button (also not a real submit button because you don't want to leave or reload the page). The OnClick function of that button would send an ajax request with the message details after some JS validation.

                      This is pretty crude and incomplete, but may get you started on the click function for the "submit" button of the popup form:

                      Click function:

                      /* Get the variables recipientId, subject, and message from the form. 
                            The Recipient ID  and sender ID would be hidden fields with a placeholder
                            for the two IDs (set by a snippet when the page loads). */
                      
                      /* Check the variables for validity (e.g., not empty) here. 
                         If they're OK do this:  */ 
                      
                      mmAjax(senderId, 'security/message/create', {'type':'user','user':recipientId,'subject':subject,'message':message});

                      /* That will call the mmAjax function (below) which you've embedded in the
                      page as well (along with JQuery and JQuery UI). */
                      function mmAjax(id, action, dataIn) {
                      var spinnerTarget = document.getElementsByTagName("body")[0];
                      var mmSpinner = createSpinner();
                      mmSpinner.spin(spinnerTarget);

                      dataIn = dataIn || {};
                      dataIn['id'] = id;
                      dataIn['action'] = action;

                      /* Ajax call to action; calls MODX resource pseudo-connector */
                      return $.ajax({
                      type: "POST",
                      url: "mm-ajax[[+html_file_extension]]",
                      data: dataIn,
                      dataType: "json"

                      }).done(function () {
                      mmSpinner.stop();
                      alert('Your message has been sent');
                      }).fail(function (jqXHR, textStatus) {
                      mmSpinner.stop();
                      alert(action + ' failed on message ' + id + ' ' + textStatus);
                      });
                      }
                      function createSpinner() {
                      var opts = {
                      lines: 17, // The number of lines to draw
                      length: 17, // The length of each line
                      width: 4, // The line thickness
                      radius: 5, // The radius of the inner circle
                      corners: 1, // Corner roundness (0..1)
                      rotate: 0, // The rotation offset
                      direction: 1, // 1: clockwise, -1: counterclockwise
                      color: '#56A717', // #rgb or #rrggbb or array of colors
                      speed: 0.6, // Rounds per second
                      trail: 81, // Afterglow percentage
                      shadow: false, // Whether to render a shadow
                      hwaccel: false, // Whether to use hardware acceleration
                      className: 'spinner', // The CSS class to assign to the spinner
                      zIndex: 2e9, // The z-index (defaults to 2000000000)
                      top: '50%', // Top position relative to parent
                      left: '50%' // Left position relative to parent
                      };
                      return new Spinner(opts);
                      }
                        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