Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

Categories

In this Discussion

Who's Online 10

CurtisOdenericgillettex00 +7 guests

DiscussionsController_Render_Before question

@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?

Vanilla developer [GitHub, Twitter]

Tagged:

Comments

  • Posts: 2,058
    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).

    Vanilla developer [GitHub, Twitter]

  • TimTim
    Posts: 1,573
    Sorry to have missed this bro. I'll get on it tomorrow morning first thing!

    Vanilla Forums Senior Developer [GitHub, Twitter, About.me]

Sign In or Register to comment.