I've used the message module to create a notifications system on my site. It works fantastically, however the final task I would like to complete has been less pioneered via contributed modules. This is the creation of a drop down menu item that lists unread notifications. It requires several characteristics.

1. Drop down functionality. Options I have investigated:

A) Menu views. Will allow immediate attachment of an item count badge via menu badges module. Would require addition of custom drop down javascript in theme and one additional module compared to option B.

B) Quick tabs accordion. Don't set a default tab and it behaves exactly like a drop down menu toggle. No additional modules or javascript necessary.

2. A badge that counts the # of unread items in the views list attaches it to the link that activates the drop down. Menu badge provides this for option A and link badge(required by menu badge so it's installation is a given) MAY provide this for option B but I don't know how to go about doing so.

3. Removing/resetting the badge after the drop down is viewed. Rules link may be the solution to this by marking the messages in the list as read + some css that hides the badge after click until it can be updated on next page load. May be possible to use views auto refresh module to do this through ajax, but it seems like this single feature would be a little too module heavy at that point.

I want to achieve this in the most lightweight manner possible, but I'm unsure how to proceed.

Re-written for clarification.

  • Welcome to the club of fans of the Message module ...If you can/want, please support my proposal to get a dedicated tag for this great module. Apart from that: I'm familiar with the "Menu badges" module. But I just don't get it what your question is really about. Can you edit your question please to explain the functionality your question is about? Just a wild guess (I doubt it is right): "How to detect the new-ness of messages?" Also, can you rephrase your title to summarize your question in a single phrase? – Pierre.Vriens Oct 30 '17 at 20:45
  • @Pierre.Vriens I've re-written the post, hopefully it is more clear now. I've upvoted your proposal, but not sure how else to support it. I'm fairly new to stack exchange. – TheGruntler Oct 30 '17 at 21:34
  • Thanks for rewriting your question, it confirms what I was guessing (multiple questions contained in a single question). Now I do understand them all I think (though I only answered one of them). – Pierre.Vriens Oct 30 '17 at 21:54

Your question consist of (at least) 3 questions. You should really split them in separate ones. Read on for an answer to your bullet "3." ...

Have a look at my answer to "How to allow users to manage their own Message Stack messages?", which IMO is pretty close to the question here. It can be summarized like so:

  1. Create a flag (using the the Flag module).
  2. Create a view 'Messages by user'.
  3. Use Rules to flag/unflag messages.
  4. Trigger the Rules Component to mark messages (using the VBO module).
  5. Create notifications about Unread Messages (using the "Menu Badges" module).

Bonus: by using the suggestion as in item "5.", you probably also solved your bullet "2." (combined with "A.")

Note: no custom coding involved, only using some of the commonly used contributed modules (and "Menu Badges", a hidden gem ...).

|improve this answer|||||
  • Thanks, I'll divide this into separate questions tomorrow. – TheGruntler Oct 31 '17 at 4:04

I have done the exact thing you're describing here.. But it's a custom solution as the menus are built in my own tpl. I don't use Drupal's menu system.

enter image description here

Basically, there's a 'seen' flag for messages and when a user clicks their history button, a "use-ajax" link gets pressed which triggers my custom module to flag all the messages for the user.

This is the module that flags messages. I have a view that returns all unflagged messages for that user and then flag them.


function custom_ajax_flag_seen_init() {
    drupal_add_library('system', 'drupal.ajax');

function custom_ajax_flag_seen_menu() {
    $items['messages-seen'] = array(
        'page callback' => 'ajax_flag_messages',
        'access callback' => 'user_access',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
    return $items;

function ajax_flag_messages($type = 'ajax', $uid = 0) {
  if ($type == 'ajax') {
    $flag_msg = flag_get_flag('seen');
    $list = views_get_view_result('messages_vbo_seen');
        foreach($list as $activity_item){
            $flag_msg->flag('flag', $activity_item->mid, user_load($uid), TRUE); 

This is the code for the hidden link which calls the module above.

if ($unread_count > 0) {
    print '<a class="hidden use-ajax" id="seen_id" href="/messages-seen/nojs/' . $user->uid .'">seen</a>';

This is the jQuery for when the history button is clicked.

$('.menu_unread').click( function () {
    if ($('#seen_id').length) {
        //So the rule fires once only

Pierre mentioned the Rules Link module and I actually used that at first but changed to the custom module for some reason. (You can see my view has "vbo" in the name and my comment mentions rules). I honestly can't remember why so you should probably try it first. Although to be honest, the module I created is less effort.

Btw, this isn't supposed to be a working solution but it should give you ideas on your own implementation.

|improve this answer|||||

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