I need to get data from another model than the view specific controller/model into the view. But I'm not sure if the way I'm doing it now is correct.
I do that via the following way in the view.html.php file:
JModelLegacy::addIncludePath(JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_mycomponent' . DIRECTORY_SEPARATOR . 'models'); //get instance of model class, where class name will be fooModelBar $model = JModelLegacy::getInstance('Messages', 'MyModel'); //call model method $this->messages = $model->getData();
But I have a feeling this is not the "correct" way to handle things. Can anyone educate me where I actually have to put this code? I know I am probably not doing it correctly by adding the model to the view.html.php file, but I am a bit confused where I need to add it. I tried adding a display() method to the profile controller but that didn't do anything.