Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

DiscussionsController_Render_Before question

LincLinc Detroit Admin
edited October 2010 in Vanilla 2.0 - 2.8
@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?


  • Options
    LincLinc Detroit Admin
    edited October 2010
    Here's the core of my dilemma I think. In /vanilla/views/discussions/helper_functions.php in WriteDiscussion there's this:
    $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).
  • Options
    TimTim Operations Vanilla Staff
    Sorry to have missed this bro. I'll get on it tomorrow morning first thing!

    Vanilla Forums COO [GitHub, Twitter,]

Sign In or Register to comment.