I am developing a "Customer Dashboard" component in Joomla 3.2.
I need to include multiple models of different other components that I have built. I tried to include setModel as per views in controller, here is my businessservices controller

class BusinessServicesControllerBusinessServices extends JControllerForm
        public function display($cachable = false, $urlparams = false)

            // set default view if not set
            $input = JFactory::getApplication()->input;
            $input->set('view', $input->getCmd('view', 'BusinessServices'));
            $viewName       = $this->input->get('view');
            switch ($viewName)
                case 'businessservices':
                    $viewLayout = $this->input->get('layout', 'default');
                    $view = $this->getView($viewName, $format, '', array('base_path' => $this->basePath, 'layout' => $viewLayout));
                case 'trademark':
                    $viewLayout = $this->input->get('layout', 'default');
                    $view = $this->getView($viewName, $format, '', array('base_path' => $this->basePath, 'layout' => $viewLayout));
            // call parent behavior

also, I tried to include using:

    JLoader::import( 'llp','components' . DS . 'com_llp_service' . DS . 'models' );
    JLoader::import( 'opc','components' . DS . 'com_opc_services' . DS . 'models' );

and getting the model using getInstance method

$actionsModel = JModel::getInstance('trademark', 'BusinessServicesModel'); 

it is giving some fatal error, that JModel::getInstance you can not use,

so I want know some proper way to doing this task, including all features to the customer dashboard.


Try JModelLegacy:

$actionsModel = JModelLegacy::getInstance('trademark', 'BusinessServicesModel'); 

Maybe you have to include the model file if it is not found:

require_once JPATH_ADMINISTRATOR . '/components/com_llp_service/models/trademark.php';

Please note: The DS constant is not available in newer Joomla versions.

  • yes, JModelLegegacy::getInstance('trademark', 'BusinessServicesModel'); worked fine, but model file was not including using JLoder::import method, i came with your solution to add it manually using require_oince. Thanks a for the answer! Oct 10 '14 at 10:54
  • PHP itself, though, has a specific DIRECTORY_SEPARATOR constant that can be used instead of DS. Much longer, of course.
    – Ian Hunter
    Sep 9 '15 at 23:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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