2

I am just unable to use the Message module or the Activity module to record the following activities and show them in a view.

  1. User A just got 10 points.
  2. User B just became User A's friend.
  3. User C just joined the site.
  4. User D just logged in.
  5. User E just viewed "Any Blog".
  6. User F just commented on "Any Blog".

The Activity module does not provide hooks for some of this in the CMS UI itself and I am having real difficulties to configure the Message module for these cases.

There is not enough documentation for this, especially the Message module. There is one tutorial at Log Site Activity with Message and Rules but that is for only one of my cases. I haven't been able to figure out the other use cases. I don't get exactly the same options (entity and tokens) as described in the tutorial.

Any help with my use cases?

  • 1
    To see how message module works, enable "message example" module. – nit3ch Apr 2 '13 at 11:25
  • will look into it and then get back...thanks for the direction though – user145078 Apr 3 '13 at 4:40
  • I have same question,when adding a new message type,there is no Message text area to add the message.What am I missing?How did you solve this? – sokratis Dec 6 '13 at 13:41
  • @sokratis you might get it to work using the technique of "Replacement tokens" as detailed in my answer below ... – Pierre.Vriens Aug 2 '17 at 13:34
0

The Message module is great, really! But still poorly documented. However, have a look at the tutorial "How to use Rules to notify users about new or updated posts on a Drupal site?", which explains how to use the Message module, together with the Rules module. What follows is a summary of what's included in this tutorial.

You can use the Message module in combination with the Rules module create message "entities" (which is what you get if you use the Message module). And then just use the power of Views to display those messages that got created in the format you need (page, block, etc).

Here is a blueprint of what you'd need:

  1. Define an appropriate Message type, using the Message module. Think of Message types as similar to "Content types", which will be used to create Messages, similar to nodes.

  2. Create a rule with a Rules Action "Create entity" (of type "Message"). Refer to the answer in 'Which user related token(s) can be used to create a Rule for setting up a message type?' for some examples.

  3. Make sure to also add a Rules Action to pass any relevant tokens, via the Rules module, as Replacement tokens that you can use in your Message type you created with the Message module. Refer to What's the purpose of "Replacement tokens" of a Message type? for more details on this.

  4. Use Views to display the created messages in the format you prefer.

Some more details specific to your question here:

  • For each of the 6 activities you want to record, define an appropriate (corresponding) Message Type (using the Message module). Let's name those message types like M1, M2, ... M6 for now.
  • For each of the 6 activities you want to record, there is an appropriate Rules Event you can take advantage of. If you'd just create 6 custom rules (1 for each activity to record, let's name those rules like R1, R2, ... R6 for now), it's a matter of combining each rule with a Rules Action to "Create an entity" (i.e. of type "Message"). E.g. Rule R3 should have a Rules Action to create a message of type M3.
  • As per the "I don't get exactly the same options (entity and tokens) ..."-part of your question: I bet sooner or later you're going to run into the issue that you want to create a message using a token which is NOT made available by only the Message module. E.g.: Assume that for recording your 6th activity (= "User F just commented on ...") you want the message to also include the actual comment body (text) that was posted. But the Message module doesn't offer any relevant token related to that comment body. In that case, you can use the approach/solution as documented in "What's the purpose of "Replacement tokens" of a Message type?", which is basically a technique to create your custom tokens (the comment body in the example here) and make them available to the Message module (so that you can include them in the message to be created).
  • Obviously, creating appropriate views of these messages (which are just entities) should be straight forward.

More info about the Message module

There is not a lot of documentation available about the Message module, which is what makes it a hidden Drupal gem. A possible way to get started with it, and to get an idea of the kind of things it can be used for, is to also have a look at these tutorials:

Not the answer you're looking for? Browse other questions tagged or ask your own question.