I have just upgraded my site from Joomla 3.7 to 3.9 and I am getting errors related to my code for a component model class that extends an administrator component model class. The require_once line below was fine in Joomla 3.7. I replaced it with JLoader::import, but no luck.

Is the JPATH_COMPONENT_ADMINISTRATOR constant no longer valid in Joomla 3.9?

The error I'm getting is:

PHP Fatal error: Class 'NoDiceModelWidget' not found in C:\xampp\htdocs\nodice\components\com_nodice\models\widget.php on line 8

The import should be looking in C:\xampp\htdocs\nodice\administrator\components\com_nodice\models.

How can I import my administrator model to extend my front-end model?

defined('_JEXEC') or die;

//require_once JPATH_COMPONENT_ADMINISTRATOR.'/models/widget.php';

class NoDiceModelAuthorWidget extends NoDiceModelWidget
    public function __construct($config = array())

1 Answer 1


JLoader::import() is generally meant for files that follow a certain naming convention. You can still use it as it will fall back to the specified filename, but you have to pass the basepath as the second argument:

JLoader::import('components.com_nodice.models.widget', JPATH_ADMINISTRATOR);

Alternatively, you could use JLoader::register():

JLoader::register('NoDiceModelWidget', JPATH_ADMINISTRATOR . '/components/com_nodice/models/widget.php');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.