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

Error while using XFCP

Fuhrmann

Well-known member
#1
I am extending the Model Like. I added my own function:

getAllLikes (for example)

ok.

Now, i extend the ControllerPublic Member and added my own action.

Inside my action in the extending controller i want to call the function that i have created in the extending model.

But i receive this error:

"Cannot load class using XFCP. Load the class using the correct loader first."

So, i am using the XFCP in the process of extending the two classes. What are am i doing wrong?


 

Fuhrmann

Well-known member
#2
My listener:

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

    public static function load_model ($class, array &$extend)
    {
        if ($class == 'XenForo_Model_Like')
        {
            $extend[] = 'newProfileTabs_Extend_Model_Like';
        }
    }
My newProfileTabs_Extend_ControllerPublic_Member:

PHP:
<?php
class newProfileTabs_Extend_ControllerPublic_Member extends XFCP_newProfileTabs_Extend_ControllerPublic_Member
{
    public function actionUsersLike()
    {
        $userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);

        $users_likes = $this->getModelFromCache('newProfileTabs_Extend_Model_Like')->getAllGivenLikesByUser($userId, '10');
  
        return $this->responseView(
            'newProfileTab_ViewPublic_Member_UsersLike', 'newProfileTab_ourTab_content',
            array('user' => $users_likes)
        );
    }
}
?>
 

Fuhrmann

Well-known member
#3
Well, since no one gave me a response, i think i know:

I have newProfileTabs_Extend_Model_Like. This extends XenForo_Model_Like.

In my listener, i have:

PHP:
 if ($class == 'XenForo_Model_Like')
        {
            $extend[] = 'newProfileTabs_Extend_Model_Like';
        }
So, will only extends when XenForo load the class "XenForo_Model_Like". So, when i go to the profile page of any member, and try to call newProfileTabs_Extend_Model_Like, wont work, because this class do not was initialized yet. I think that's it.
 
R

ragtek

Guest
#4
why are you extending your model from likes model?
the method in your tutorial part3 doesn't need any of the parents methods...
this means you could create & use a own method:p