2

I want to create either a view or a module (preferably view) to display all recent activity on the site such as a new user joined in, a user read some article or blog, a user gained some points and so on...the display should be as:

User x just joined in
User y just got 30 points for creating a blog
User Z just read Some Article 

I tried doing so using the Message, Views and Rules modules, but I was able to do so (only for one specific event such as User x created a blog ...).

Note: I want to create new events in Rules. I wonder how to use a message type to get different messages to be displayed. I am following this tutorial, but I wonder how to add more messages such as "[user] gained [user-points]", etc and be sure that it is displayed when that event triggers. Also what data selector should I choose in Rules?

3 Answers 3

2

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 3 activities you want to record, define an appropriate (corresponding) Message Type (using the Message module). Let's name those message types like M1, M2, ... for now.
  • For each of the activities you want to record, there is an appropriate Rules Event you can take advantage of. If you'd just create a custom rules (1 for each activity to record, let's name those rules like R1, R2, ... 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.
  • 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 an activity like "User X 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:

1

You should take a look at the Heartbeat module.

Heartbeat displays user activity on a website. This module is an API to log activity. The logged data contains message structures, attributes and variables. Once the activity messages exist in the database, they will be parsed and build into activity streams.

screenshot

6
  • But Hearbeat would soon be gone. I tried using Message module but am not clear
    – why
    Jan 21, 2013 at 5:04
  • What part of it did you not understand? Jan 21, 2013 at 5:06
  • i want to create new events in Rules...and also in message type i how do i get different messages to be displayed..i am following the tutorial at webwash.net/tutorials/log-site-activity-message-and-rules..but there how do i add more message such as [user] gained [user-points] etc and be sure that it is displayed when that event triggers...also what data selector should i choose in rules
    – why
    Jan 21, 2013 at 5:12
  • Also, what would be the better choice in your opinion..Message module or Activity module
    – why
    Jan 21, 2013 at 5:15
  • I would go with message if you are comparing with activity and message. that seems to be more stable Jan 21, 2013 at 5:21
0

If you enable views module you will see a default view called Tracker that lists all new activity in the system. Enable it. You can change the view setting to suite your needs.

1
  • The tracker page is a list of recently changed posts; it doesn't show which users has recently logged in. You could shown when the user who edited a post logged in, eventually, but not when a user logged in without editing any post.
    – apaderno
    Jan 21, 2013 at 4:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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