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.
$Sender->DiscussionID vs $Sender->EventArguments['Discussion']->DiscussionID
I'm a little confused about these two. I needed to set a plugin's class property and had to perform a SQL query using the current DiscussionID. By trial and error I discovered that I need to use $Sender->DiscussionID with, for lack of a better word, "constructor" events (like DiscussionController_Render_Before) and Sender->EventArguments['Discussion']->DiscussionID with regular events.
Can someone tell me what's the difference and why do they return different values at different stages of execution?
Can someone tell me what's the difference and why do they return different values at different stages of execution?
0
Comments
When events are called from more generic places, such as theme templates or generic helper functions, then there is less context - values such as the discussion ID are more likely to only exist as variables in the caller, and so need to be passed into the event as EventArguments in order for the event to see them.
Similarly, if an event is called up from a controller (Comments, say) in a loop, then the ID for the loop will likely be passed in as an EventArgument.
That's my observation at least, but I don't think there is any hard and fast rule. It just needs some inspection of the Sender code.
Vanilla Forums COO [GitHub, Twitter, About.me]
Im trying to get discusision id on base render without any luck
@NabUser start a new discussion
grep is your friend.