In yii, if we use modules to distinguish the front and back ends, we need to use their own layout files in different modules. during use, we find that we often cannot call layout in modules, the following describes how to call modules correctly: 1 components/controller. the value of public $ layout is defined by default in PHP. Once the value is set here, layout cannot be correctly loaded to layout if the name of layout is different from that of the module layout, therefore, it is best to comment out such code and switch to the xxxxmodule of each modules. set the value of the control layout variable in the init method of PHP; 2 in the xxxxmodule of each modules. in PHP, The init method sets the value of the layout variable of modules in several ways: First, $ this-> layout = 'index'; second, $ this-> layout = '/layouts/Index'; third, $ this-> layout = 'xxx. views. layouts. index'; // XXX indicates the module ID. For the second method, if it is set to $ this-> layout = '// layouts/Index //, the layout of protected/View/layouts/index is loaded by default;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service