• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Loading Controllers

Robust

Well-known member
#1
I don't think my controller is loading properly

Error:

The following error occurred:
The controller XenForo_ControllerPublic_Member does not define an action called Userslike.
If I throw my function directly into XenForo_ControllerPublic_Member it works fine. Outside of that, I get that error.

Code:
class newProfileTabs_Extend_ControllerPublic_Member extends XFCP_newProfileTabs_Extend_ControllerPublic_Member
{
    public function actionUsersLike()
    {
        $userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);
        $user = $this->getHelper('UserProfile')->assertUserProfileValidAndViewable($userId);
        $users_likes = $this->getModelFromCache('newProfileTabs_Model_newProfileModel')->getAllGivenLikesByUser($userId, '10');

        return $this->responseView(
            'newProfileTab_ViewPublic_Member_UsersLike', 'newProfileTab_ourTab_content',
            array('user' => $user, 'users_likes' => $users_likes)
        );
    }
}
Listener:

Code:
public static function load_controller($class, array &$extend)
    {
        if ($class == 'XenForo_ControllerPublic_Member')
        {
            $extend[] = 'newProfileTabs_Extend_ControllerPublic_Member';
        }
    }
 

Chris D

XenForo developer
Staff member
#2
The event hint is wrong.

The event hint should be the name of the class you are extending.

This also means you don't need the if ($class == whatever) bit in the listener.
 

Steve F

Well-known member
#3
In your error
The following error occurred:
The controller XenForo_ControllerPublic_Member does not define an action called Userslike.
The controller
newProfileTab_ViewPublic_Member_UsersLike
 

Robust

Well-known member
#5
Aaand... Issue

The server responded with an error. The error message is in the JavaScript console.

[Error] PHP q{"templateHtml":"","js":"","css":"","term":"Like","cssClasses":{"like":"+","unlike":"-"},"_visitor_conversationsUnread":"0","_visitor_alertsUnread":"0"}
handleServerError (xenforo.js, line 231)
error (xenforo.js, line 226)
j (jquery-1.11.0.min.js, line 2)
fireWith (jquery-1.11.0.min.js, line 2)
x (jquery-1.11.0.min.js, line 4)
b (jquery-1.11.0.min.js, line 4)