Difference between view.php and _view.php in yii

What is the difference between view.php and _view.php in Yii?

Where should I use from _view or view in Yii?

Can I render both with render () or renderPartial ()? not a performance issue or something else?

+4
source share
1 answer

These are just file names, but by default, view.php is used with render() , and _view.php is used with renderPartial() (in the default Yii web application).

Therefore, if we adhere to this convention, any representation displayed by render() will be the "normal" file name, and anything displayed using renderPartial() will be prefixed with _underscore.

Here is the difference between render and renderPartial (from here ):

render() usually used to render a view that matches what the user sees as a β€œpage” in your application. First, it displays the view you specified, and then displays the layout for the current controller action (if applicable), placing the result of the first render in the layout. Then it performs the output processing (which at this time means automatically inserting any necessary <script> tags and updating the dynamic content) and finally outputs the result.

renderPartial() usually used to render the "part" of a page. The main difference from render() is that this method does not put render results in the layout. By default, it also does not process output, but you can override this behavior with the $processOutput parameter.

+7
source

All Articles