I am trying to display a component in a module which seems to work using this example http://www.escope.cz/en/blog/94-how-to-load-component-in-a-module
I am now facing a problem where my model isn't getting loaded and I'm sure it's to do with this line
$controller->addModelPath(JPATH_SITE . DS . 'components' . DS . 'com_helloworld' . DS . 'models' . DS . 'user.php'); I have done a var_dump($controller) and don't find any reference to user.php. I'm not sure what to look for in the output but i know user.php doesn't come up in any search.
The component works fine not in the module so it's not the component
UPDATE
I added this line which now includes the model and I can now use the model to call $this->msg = $this->get('Msg');
require_once (JPATH_SITE . DS . 'components' . DS . 'com_helloworld' . DS . 'models' . DS . 'user.php'); But now I get this alert pop up
JForm::getInstance could not load file
If I try to do a var_dump() in the view.html.php on the model it returns null
Here is the entire module code
<?php /* * @package Joomla 2.5 * @author Jan Linhart * @authorurl http://www.escope.cz * @license GNU/GPL * * YourModule module - main script */ defined('_JEXEC') or die('Restricted access'); if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR); $view = JRequest::getCmd('view', null); $layout = JRequest::getCmd('layout', null); $task = JRequest::getCmd('task', null); JRequest::setVar('option', 'com_helloworld'); JRequest::setVar('view', 'user'); JRequest::setVar('layout', 'default'); JRequest::setVar('task', 'display'); $lang = JFactory::getLanguage(); $lang->load('com_helloworld', JPATH_SITE); if (!class_exists('HelloWorldController')) { require_once (JPATH_SITE . DS . 'components' . DS . 'com_helloworld' . DS . 'controller.php'); } // THIS HAS BEEN ADDED TO INCLUDE THE MODEL require_once (JPATH_SITE . DS . 'components' . DS . 'com_helloworld' . DS . 'models' . DS . 'user.php'); $controller = new HelloWorldController(); $controller->addModelPath(JPATH_SITE . DS . 'components' . DS . 'com_helloworld' . DS . 'models' . DS . 'user.php'); $controller->setProperties( array( 'basePath' => JPATH_SITE . DS . 'components' . DS . 'com_helloworld', 'paths' => array( 'view' => array( JPATH_SITE . DS . 'components' . DS . 'com_helloworld' . DS . 'views' ), 'model' => array( JPATH_SITE . DS . 'components' . DS . 'com_helloworld' . DS . 'models' ) ) ) ); $controller->execute('display'); echo '<pre>';var_dump($controller);echo '</pre>'; // revert system vars to previous state // if($option != null){ // JRequest::setVar('option', $option); // } if($view != null){ JRequest::setVar('view', $view); } if($layout != null){ JRequest::setVar('layout', $layout); } if($task != null){ JRequest::setVar('task', $task); }