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

Cannot load class using XFCP. It must be simple but I just can't see it....

Discussion in 'XenForo Development Discussions' started by Marcel, Aug 25, 2014.

  1. Marcel

    Marcel Active Member

    Contents of MaB/Arch/Model/Thread.php
    class MaB_Arch_Model_Thread extends XFCP_MaB_Arch_Model_Thread
    	public function getArchThreads(array $conditions, array $fetchOptions = array())
    		$whereConditions = $this->prepareArchThreadConditions($conditions, $fetchOptions);
    etc etc etc
    My listener :
    * Listen to Event : load_class_model
    * Event Hint : None
    * Execute Callback : MaB_Arch_Listener::extendModel

    Contents of MaB/Arch/Listener.php
    public static function extendModel($class, array &$extend) {
    		if ($class == 'XenForo_Model_Thread') {
    			$extend [] = 'MaB_Arch_Model_Thread';
    I'm sure it must be something simple. I have tried adding in an event hint of "XenForo_Model_Thread", and removing the if statement from Listener.php
    I've also tried changing the listener to load_class instead of load_class_model?

    What am I missing?
    (Incase you were wondering, my Model/Thread.php has revised versions of getThreads (getArchThreads) and prepareThreadConditions (prepareArchThreadConditions)).
  2. Daniel Hood

    Daniel Hood Well-Known Member

    Are you trying to access your class directly? i.e. something like $model = XenForo_Model::create("MaB_Arch_Model_Thread"); because you can't do that. You're supposed to still call $model = XenForo_Model::create("XenForo_Model_Thread"); and that will include yours which extends the original thread model.
    Chris D likes this.
  3. Marcel

    Marcel Active Member

    Sorry for the delay in replying.
    I was indeed! What a plum I am :)
    Made those changes and all is well with the world again, thank you ):

Share This Page