2

Which is the correct/best method of calling model methods inside view.html.php.

Method 1

$mydata = $this->get('MyData') ;

Method 2

$model = $this->getModel() ;
$mydata = $model->getMyData() ;

I feel is the Method 2 is the best because I can even pass arguments to the model (if required).

2

I think $mydata = $this->get('MyData'); is the best way to call model's functions if you don't need to pass any argument.

Model's function are already available in the MVC view logic and using the second method to reload the model feels redundant to me. Usually I write my component's model functions using only arguments passed trough GET or POST and write other functions, that needs args, in the Helper class.

  • Calling getModel does actually reload the model it just returns a reference to the instance. – Mathew Lenning Nov 20 '15 at 11:34

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.