• 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?

x3sphere

Active member
#1
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';
            }
        }

}
 

x3sphere

Active member
#2
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();