Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass arguments / parameters to model

Following the tutorial how to create a joomla 2.5 component I'm stucked to pass arguments from view.html.php to my model.

$items = $this->get('TableData');

and my TableData model would expect to get the following arguments

 public function getTableData($table, $index_column, $columns) {}
like image 811
fefe Avatar asked Mar 09 '26 14:03

fefe


1 Answers

You can not do this using the view's get method. Instead you would have to grab the model into the view and call the function directly in the view:

$model = $this->getModel();
$items = $model->getTableData($table, $index_column, $columns);

Alternately, you could create different entry points in the model that would be able to figure these input options either from state information or preset. Many would argue that this would lead to a better application design, since using my code above is putting what should be model logic in the view.

like image 56
David Fritsch Avatar answered Mar 11 '26 08:03

David Fritsch