Extend an administrator class in the front end code

by kalinma   Last Updated October 19, 2019 00:10 AM - source

I have just upgraded my site from Joomla 3.7 to 3.9 and 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 not 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?

<?php
defined('_JEXEC') or die;

//require_once JPATH_COMPONENT_ADMINISTRATOR.'/models/widget.php';
JLoader::import(JPATH_COMPONENT_ADMINISTRATOR.'/models/widget.php');

class NoDiceModelAuthorWidget extends NoDiceModelWidget
{
    public function __construct($config = array())
    {
        parent::__construct($config);
    }
}
Tags : jloader


Related Questions