1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Grabbing conversation message id for template hook

Discussion in 'XenForo Development Discussions' started by Jeremy P, May 30, 2011.

  1. Jeremy P

    Jeremy P Well-Known 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.
     
  2. SheepCow

    SheepCow Well-Known Member

    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 :)
     
  3. Jeremy P

    Jeremy P Well-Known Member

    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. :)
     
  4. Jeremy P

    Jeremy P Well-Known Member

    Wrong thread? ;)
     
  5. SheepCow

    SheepCow Well-Known Member

    Heh, indeed.
     
  6. SheepCow

    SheepCow Well-Known Member

    See Kier's reply in the thread I linked to, he's added params to the hook for 1.0.3 :)
     

Share This Page