Render method in CakePHP

Aug 27, 2020 PHP beginner render programming study diary

#Programming study diary August 27, 2020 I used the render method in Rails, but since it can also be used in CakePHP, I will summarize the render method.

What is the #render method A convenient method when you want to draw another view file. The Controller::render() method is automatically called at the end of each action to render the view. Therefore, it is very convenient to use the render method when specifying another view file.

#How to use If the argument is not specified in the render method, the view file will be called as usual. If no argument is specified, the view file is automatically called without using the render method, so it is not necessary.

$this->render();

If you specify an argument in the render method, you can specify another view file in the argument. The view file specified by this argument is displayed.

$this->render('/test/testSample');

#important point The render method draws the view file using the data passed by the set method. Therefore, if the render method is specified first, the subsequent processing will not be executed, so pay attention to the order of writing.

References

[Introduction to CakePHP] Specify an arbitrary View file with the render() method