I'm using the Message module to create messages on certain events, for example, on forum node creation:

"X has posted a new thread in the Y forum."

I've got a view that spits all of these out.

I now want to create a new view that shows the same messages, but in this view, I want to change the output of the above message to:

"You have posted a new thread in the Y forum."

Every time the node's author matches the currently authed user.

Now my thoughts would be that I could somehow intercept the output of either the token (X) or override the whole message entity template, but I'm not entirely sure how to go about this.

Another thing I tried was to create a new user token, called "Username or you", which would output "you" if the associated message node matched the authed user, or the username if not. However, I'm not sure how I could get the message object. It's worth noting that I have the token:


So if I could follow the trail back to "message" and get the message id, I'd be all set.

Any pointers?


See the Messaging documentation, specifically this overview on new features. You likely want to override the tokens provided using a callback which is supported by the module:

Callbacks: sometimes we can’t use the token system, for example if we need to show different results based on the value of _two different fields. This is an advanced feature, which is meant for developers, and is documented in the module.

I've not done this myself yet, but I've used the Message module and Views -- digging through the module and documentation should get you there now that you know it's possible.

From the message_example README it sounds like you want an activity stream:

The UAS (User activity stream) view is dependent on Panels, as it uses "Panel fields" as a row plugin, along with the Message's partials.

Which you should be able to look at for inspiration in the example module.

| improve this answer | |
  • Thanks, callback was the perfect solution as it updates in realtime rather than retrieving from the database. – njp Jul 28 '14 at 9:08

If you are willing to (also) use the Rules module, you might be able to make a token such as username_or_you (as in your question ...) available by using the Replacement patterns for each message type.

So the answer to your question is "Whatever token you're missing, just make it available via Rules, by creating a replacement token for them". Refer to the answer to What's the purpose of "Replacement tokens" of a Message type? for way more details on that.

These Replacement tokens are really a hidden gem about how Rules integrates with Message. For an example to see them at work, refer to my answer to "Which user related token(s) can be used to create a Rule for setting up a message type?".

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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