Answer the question
In order to leave comments, you need to log in
MVC model in Yii?
I am developing on Yii, and when implementing some features, seditious thoughts crept in - but do I understand everything correctly and the best practice project corresponds.
As I understand
MODEL - data. Binding to a table/view.
Question - are all used functions stored in the model? Even if they are used exclusively in one view?
CONTROLLER - binds data and view. This is if it's rude to take the URL. When accessing some url, we get certain data. similar to ajax in principle.
The question is what else is included here (besides the default layout, roles, etc)
VIEW - determines what we see in the browser. What color will the text be, will it be a text field or a calendar, and so on.
A question - whether has the right to be here and to functions. Such a file with everything you need is obtained.
----
Other questions - where are the scripts for individual views connected?
At what level do you need to edit css for individual views? Directly in view? If I use several widgets, does this greatly affect performance or do I need to reduce their number?
Answer the question
In order to leave comments, you need to log in
1. According to the model, the understanding is correct, the task of the model is to work with data
2. The controller receives data from the model and passes it to the view
3. The view, as a rule, is html code with the introduction of data from the controller
4. Functions in the view are not acceptable
5. Connecting scripts and styles in the controller
6. Css is edited in the style file that we include in the controller, css in the view file, bad practice
7. It is better to push the project styles into one file, since it will be loaded once and cached in the browser, and will be taken from the cache on subsequent calls
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question