Grabbing conversation message id for template hook

Jeremy P

XenForo developer
Staff member
In 1.0.2, the template hook "conversation_message_private_controls" was introduced in the "conversation_message" template. I am trying to make use of it to add a new control.

In my template hook listener I have something like
PHP:
$template->create('conversation_message_control_report', $template->getParams())->render();

That template tries to make use of $message.message_id, but it is not available to it. When I manually include the contents of the template in the hook, it can make use of the variable correctly.

It's likely I'm making a stupid mistake, would appreciate a nudge in the right direction.

Thanks.
 
I don't think you can get it easily. Because it's an include of an include in a foreach loop you don't get the $message, you've got the array with all the messages in, and no easy way to knowing which message you're looking at.

There's a similar problem with the public/private post controls. My work around at the moment is to regex out the ID from the "reply" link in a post.

I think it's an oversight :)
 
Usually in those situations it was my understanding that the looped item was included in the hook's parameters. I would agree this is definitely an oversight.. I can't think of much you can do with per message controls if you can't access message data.

Thanks though for the regex idea, I guess I'll have to work out something similar in the meantime. :)
 
Top Bottom