I'm curious as to where to get data from
JInput in the MVC design pattern. For example, in a situation where I need a
JInput value to use in a query in a model class method, should I get the
JInput value there or should I pass it from the view or does it matter?
In a proper MVC structure, only your controller should interface with your request data, in this case
With the current CMS structure, all three pieces of the MVC structure are often interfacing with the request data. In models, this is usually done in the
I'm of the strong belief that it should be retrieved where appropriate.
That is to say you should always use
JInput doesn't offer such feature; so you might have to use $_POST.
if you can have the input be in the form of array (and use JInput::getArray() )
a json-encoded object (you use json_decode(JInput::getString()))
Though already answered, I'll try to explain in my on perspective.
Joomla! is a really great and flexible MVC Implementation.
About your problem of populating a View, with data from Model, depending on the user submitted data through $_GET. Here is how I do it.
First thing I'd like to state is that Besides the common Models, Views and Controllers there is another category of files used widely in Joomla!, those are the mini-Controllers. Yup you read it correct.
These are the files directly inside the view folder.
Here are a few of them.
Apart from serving the purpose of generating different types of output, they also serve as a controller(In a way).
So for case like yours, one doesn't have to involve controllers just to get the data from the model. All you have to do is get the submitted data using jinput sanitize it and the pass the data as an object or array or just plain variable, to the Model.
Heres an example:
Disclaimer:- Remember that this is my own implementation, and may not be that perfect way, so get this approved by the pros before using any of my code in production environment.
Note:- I know JRequest is deprecated, but its there to stay as per the Joomla! core team, since the core too uses it all over the place.