Possible Duplicate:
How to use multiple models in joomla MVC Component
In J!2.5 Tutorial there is just one model (the default one) loaded in the view. An the snipplets from J!1.5 doesn't work anymore together with the use of techniques from the tutorial. Here is the turoial stuff extended with mine. controller.php
function display($cachable = false)
{
// set default view if not set
$input = JFactory::getApplication()->input;
JRequest::setVar('view', JRequest::getCmd('view', 'HelloWorlds'));
// We will add a second model "bills"
$model = $this->getModel ( 'helloworlds' ); // get first model
$view = $this->getView ( 'helloworlds', 'html' ); // get view we want to use
$view->setModel( $model, true ); // true is for the default model
$billsModel = &$this->getModel ( 'mycomponents' ); // get second model
$view->setModel( $billsModel );
// call parent behavior
parent::display($cachable);
}
And here is my view. views/helloworlds.view.hml.php
function display($tpl = null)
{
// Get data from the model
$model = $this->getModel();
$items = $this->get('Items');
$pagination = $this->get('Pagination');
$model2 = &$this->getModel('mycomponents');
$items2 = $model2->get('Items');
$pagination2 = $model2->get('Pagination');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode('<br />', $errors));
return false;
}
// Assign data to the view
$this->items = $items;
$this->pagination = $pagination;
$this->items2 = $items2;
$this->pagination2 = $pagination2;
// Display the template
parent::display($tpl);
}
But unfourtunately, there is no model2 loaded. Whats going on here? Is my error in the controller? Do have set both models correct with in the controller? And what about my code in the view? Do I have to load the model in that way (known from J!1.5)?
Best Regards Björn