Is there a function that lets me check if the message is the last message in a conversation/PM?

CommentFileSizeAuthor
#6 css_classes.patch3.32 KBberdir

Comments

berdir’s picture

Status: Active » Postponed (maintainer needs more info)

No, there isn't.

I guess the only easy thing would be to load the whole thread and then look at the messages array.

What are you trying to do?

Michsk’s picture

i want to change some visual things on the last message.

berdir’s picture

Status: Postponed (maintainer needs more info) » Active

Ok, so we're talking about theming :)

I think it would be useful to have the same classes that listings/tables have by default... first/last/even/odd.

Michsk’s picture

That would be great yes. But i would also really love to just have a function that returns me if the current $message is the last, just like we do with is_new.

litwol’s picture

@#3 yep. similar to the way core menu items do it. first, menu-item-N, last, etc etc. (even and odd too :) )

berdir’s picture

Status: Active » Needs review
StatusFileSize
new3.32 KB

#4: That would be enough, but it would actually be more complicated than it sounds, because a single message does not know anything about the thread.

Adding a bunch of CSS classes is much easier, please try the attached patch.

Michsk’s picture

Ok this is a good start. I really need a is_last tough, i need to add some extra content when the message is last. Real html content not only theming. Guess i'll have to wait. But could we make a new issue for the css class to keep things clear?

berdir’s picture

All you need to do then is check if one of the classes is "privatemsg-message-last", you should be able to use the following code in privatemsg-view.tpl.php:

if (in_array('privatemsg-message-last', $classes)) {
  echo "last message";
}
Michsk’s picture

yeh lol, this also just came to me a sec ago. Thanks!

berdir’s picture

Hehe, ok, please report back once you got it working, then I'll commit the patch.

Michsk’s picture

Will do. Probably today.

berdir’s picture

Did you have a chance to test this? ;)

BenK’s picture

Subscribing...

Michsk’s picture

bit late, but wil do this today. Working on the project at this moment so wil do this also.

Michsk’s picture

Status: Needs review » Reviewed & tested by the community

works like a charm.

berdir’s picture

Title: Last message in conversation » Odd/even, first/last css classes to messages on thread view page.
Version: » 7.x-1.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Commited.

Also changing issue title and moving to 7.x, will port later.

berdir’s picture

Status: Patch (to be ported) » Fixed

Ported and commited to 7.x-1.x

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.