2

I have created a view, which shows activity logged by Message module.

I then created a menu badge which shows the numbers on the menu item. - In start, when there is no activity, it shows 0, After there is some activity it shows the count, but when the page is viewed the count remains the same and does not decrease or disappear.

When the whole activity page is viewed, the numbers should disappear.

2
  • You might want to reword your post to include an explicit question. Right now it reads like a bug report, which are flagged off topic here.
    – Shawn Conn
    Commented Aug 7, 2016 at 18:04
  • Hey @ShawnConn, this is, IMO, not about a bug. Instead it's an "interesting" (I think) how to question ... Have a look at my answer for more details ... Commented Aug 8, 2016 at 9:23

1 Answer 1

1

Part 1 - It does seem to work as designed

Since your question is about a "Menu badge", I'm assuming you are using the (great!) Menu Badges module to create such badge, whereas you also created a view (using the Views module).

To make it all work, your view should show the number of rows corresponding to the "activity logged by the Message module" (as in your question).

And the view seems to be OK if there is no activity (it shows "O"). However, if the count remains the same later on, then it must be because the result of your view doesn't change either. If you want that number produced by the Menu Badges module to change, then you must make sure that the view produces the correct number. So if that number doesn't change, it is about sure (not just probably ...) because something in the filter of your view is not correct. Like does your view only select the rows which have some kind of "new activity" indicator? If not, what other filter do you have to make that number decrease?

So IMO this is not a bug in the module, but rather just a customization error in your view (head over to Part 2 for more details on that).

Part 2 - What you're missing in your view

I think Part 1 of my answer is "the" answer to your question, but here is an attempt to also, partially, answer your additional comment (which is really a new question I think):

If there is new activity, the number does increase, but do not decrease or disappear as in case of private messages. What I have understood so far of menu badges is that you have to put something in the fields section and turn on aggregation so that it knows what to count. Currently I am using Message:Message ID in the field. What filter I should use?

Not sure where the "private messages" refers to (I'm just going to consider that as "a" type of messages). But you're right about that "you have to put something in the fields section and turn on aggregation so that it knows what to count": that is the "clue" about what the Menu Badges is all about. Let's consider the Message View (where the below screenprints originate from) that comes with the Message module, i.e.:

enter image description here

Here is a screenprint with the design details of that view:

enter image description here

If you'd use the Add button for "fields", and then filter the available fields for "Message:", you would only get these fields:

  • Language
  • Message ID
  • Render message (Get text)
  • Rendered Message
  • Timestamp
  • Type
  • User uid

Obviously, none of these fields contain any information if it is yes or no a "new" message. So that's what you're missing and why out-of-the(-message)-box you cannot get this to work. To better explain this (what you're missing): have a look at the "tracker" view (disabled by default), which has the fields "Content:Has new content" and "Content:Has new comments". Those are 2 perfect fields to use if you want to use Menu Badges to get notified whenever there is new content, or new comments.

A possible compromise, and maybe partial solution for your scenario could be that you'd use the Timestamp field as your filter. E.g. if you'd filter it like "only the ones from the last 24 hours", that should have some effect.

Part 3 - How to get it to work anyway

There is a way to get this to work anyway ... Because messages are fieldable. So simply (hm, hm) add a boolean field like "Message is new" (Yes/No). It'll then also show up in the list of fields you can select from in your view (in the list of available fields as in Part 2). And with that you have a perfect solution for what you're trying to get to work.

However, there is one more challenge left: add appropriate logic to maintain the value of that boolean field. If you wonder how to do that (also), just ask a new question.

5
  • If there is new activity, the number does increase, but do not decrease or disappear as in case of private messages. What I have understood so far of menu badges is that you have to put something in the fields section and turn on aggregation so that it knows what to count. Currently I am using Message:Message ID in the field. What filter I should use?
    – Umair
    Commented Aug 8, 2016 at 7:31
  • @Umair : check my updated answer ... Commented Aug 8, 2016 at 10:18
  • Thank you for the detailed answer. By private messages I mean the private messages module. I tried to put boolean field, but it is showing only two options. "Single on/off checkboxes" and "checkboxes/radiobuttons". Secondly, there are 3 types of activities I am showing in one view. I guess I did not understood your solution or may be it is in-complete.
    – Umair
    Commented Aug 9, 2016 at 11:58
  • @Umair : you first mentioned "private messages" in your prior comment to my answer. Nowhere in your question there is an indication of that. To avoid making your question a cameleon question (= answer to the question, changes the question, and invalidates a prior answer), how about posting a new question as a followup to this question (+ a link to this one)? PS: if you agree, maybe you want to mark this answer as "good enough" also? Commented Aug 9, 2016 at 12:06
  • marked. ok may be. I guess I wrote it incorrectly. The current problem is only relates to "message module" which is a logging utility. Secondly, I was just giving an example of the "private messages module" in the comment you are referring to, this module is only used for user sending a message to other user. The menu badges module comes with a default menu badge for private messages module which works perfectly. When I read the private message, the badge disappears. This is the problem I am having with the messages (activity logs). The badge is not disappearing. I will post new Q.
    – Umair
    Commented Aug 9, 2016 at 12:33

Your Answer

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

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