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

Using add-ons on non-XF page?

Discussion in 'XenForo Development Discussions' started by x3sphere, Jan 22, 2015.

  1. x3sphere

    x3sphere Active Member

    Is there anything special I need to do to access add-ons outside of XF? I've initialized the XF environment, but none of my add-ons are accessible through the models I'm extending. It appears the add-ons aren't loaded at all, not even the LoadClassModel is called. The add-ons work fine on actual XF pages, however.

    Here's my initialization code:

    Code:
                $startTime = microtime(true);
                $forumpath = 'path';
    
                require_once($forumpath . '/library/XenForo/Autoloader.php');
                XenForo_Autoloader::getInstance()->setupAutoloader($forumpath  . '/library');
    
                XenForo_Application::initialize($forumpath . '/library', $forumpath);
                XenForo_Application::set('page_start_time', $startTime);
                XenForo_Application::disablePhpErrorHandler();
                XenForo_Application::setDebugMode(true);
    LoadClassModel example:

    Code:
    class Exophase_Listener_LoadClassModel
    {
    
            public static function loadClassModel($class, &$extend)
            {
    
                if ($class == 'XenForo_Model_Post')
                {
                    $extend[] = 'Exophase_Model_Post';
                }
    
                if ($class == 'XenForo_Model_User')
                {
                    $extend[] = 'Exophase_Model_User';
                }
            }
    
    }
     
  2. x3sphere

    x3sphere Active Member

    Figured it out earlier today. You need to add these two lines after initializing XF, then add-ons will be accessible:

    Code:
    $dependencies = new XenForo_Dependencies_Public();
    $dependencies->preLoadData();
    
     

Share This Page