XF 2.3 detect widget position

QuackieMackie

Active member
I have a widget in the position Member view: Sidebar, this widget can be placed in other locations without any problem though, but I want to detect when the widget renders in the position Member view: Sidebar so I can perform a different action.

Is there a way to do that, and if so can someone point me in the right direction?

This is what i've tried so far in my render function:
PHP:
Logger::debug("Rendering UserPetWidget for user_id: {$visitor->user_id}", [
    'widgetConfig' => $this->widgetConfig
]);

Logger::debug('Widget context params', [
    'contextParams' => $this->contextParams
]);
 
Okay I don't know how well this is going to perform long term, but fetching the profile details is simply like this:
PHP:
$profileViewing = $this->contextParams['user']['user_id'];
if ($profileViewing) {
    Logger::info("UserPetWidget: Viewing profile of user ID " . $profileViewing);
}

So I guess if I want to render it differently then my render is going to rely on this single if statement.

I've tried a few positions rendering the widget, and it has only triggered for widget pos Member view: Sidebar so far. We shall see how that works long term :)
 
Back
Top Bottom