In privatemsg_view(), the participants are being added to the $content array using #markup and the theme() function:
$content['participants'] = array(
'#markup' => theme('privatemsg_recipients', array('thread' => $thread)),
'#weight' => -5
);
As well, the messages are also being added in #markup using the theme() function:
$content['messages'][$pmid] = array(
'#markup' => theme('privatemsg_view', array('message' => $message)),
);
Unfortunately, this means that the participants and messages cannot be altered after this point as they have been rendered. Switching to a render array lets the objects be altered by other modules before they are rendered.
Recipients:
$content['participants'] = array(
'#theme' => 'privatemsg_recipients',
'#thread' => $thread,
'#weight' => -5
);
Messages:
$content['messages'][$pmid] = array(
'#theme' => 'privatemsg_view',
'#message' => $message,
);
I've just run into the issue where I needed the timestamp of the last private message for a script I'm writing, but I wasn't able to get it as the messages were already rendered into HTML. By making this switch, I was able to get the timestamp in hook_privatemsg_view_alter().
Comment | File | Size | Author |
---|---|---|---|
#1 | content-themed-too-early-1736446-1.patch | 721 bytes | Jaypan |
Comments
Comment #1
Jaypan CreditAttribution: Jaypan commentedAttached is a patch to fix this.
Comment #2
ptmkenny CreditAttribution: ptmkenny commentedComment #4
ptmkenny CreditAttribution: ptmkenny commented#1: content-themed-too-early-1736446-1.patch queued for re-testing.
Comment #6
Jaypan CreditAttribution: Jaypan commentedThis issue is so old, and I ended up writing my own private message module and don't even use the privatemsg module anymore, so I'm closing it.