@Tim, I've got this in a plugin:
public function DiscussionsController_Render_Before(&$Sender) {
foreach($Sender->Discussions as &$Discussion) {
if($Discussion->Prefixed == 1)
$Discussion->Name = C('Plugins.DiscussionPrefix.Prefix').' '.$Discussion->Name;
}
}It works swimmingly on the index page, but fails to work on /mine and /bookmarked.
- The code *triggers* on /mine and /bookmarked (tested with 'exit')
- The ->Prefixed value is correctly set on those pages too (echoed the value)
I'm pretty sure it's a passing-by-reference issue, but I can't figure out how the Index() and Mine() methods in the DiscussionsController are doing anything differently other than the conditions being passed to Get().
Any idea what I'm doing wrong?
Comments
$Sender->EventArguments['Discussion'] = &$Discussion;...
$DiscussionName = Gdn_Format::Text($Discussion->Name);
So what we've got here is "hey, you can have the discussion as a referenced event argument, but HAHA you can't change the title because no event fires before we store it in a local variable!" o_o
If I could change the title there, I wouldn't have to use my Render_Before kludge on the entire controller (that doesn't work anyway, it seems).
Vanilla developer [GitHub, Twitter]
Vanilla developer [GitHub, Twitter]
Vanilla Forums Senior Developer [GitHub, Twitter, About.me]