YII implements layout, and yii implements Layout

Source: Internet
Author: User

YII implements layout, and yii implements Layout

Layout file:

<Div> I am the header </div> <! -- Display code information such as homepage, logon, and registration --> <! -- $ Content indicates the homepage, logon, registration, and other page information that we have extracted (no header or foot) --> <? Php echo $ content;?> <Div> I am the tail </div>

Location:


The layout file has been implemented. We need to use this layout file below

The default layout file in our system is colum1.php.

Use layout files:


What is the relationship between layout files:

Controller rendering view renderPartial () This method does not render the Layout

The render () method renders the layout.

Now we have completed the layout:

1. Create the layouts/Name of the layout file, and use $ content to represent the common template content.

2. Set the layout file. In the parent class controller, public $ layout = "// layouts/shop ";

3. Call the layout file. Use the method render () in the Controller Method to call the layout file.


Another method is implemented through frameset:

<! -- Set the header, left, and right through the frameset tag set in html --> <! Doctype html public "-// w3c // dtd xhtml 1.0 frameset/en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-frameset.dtd"> 




In yii, can the layout be used in the modules? Another layout means that one layout at the front end has another layout at the backend.

Certainly. In modules/your module name/components/controller. specify the public $ layout attribute in the php file, which is the name of modules/your module name/views/the layout file name you need ..
Hope to adopt it. If you have any questions, you can ask again.

How does yii remove the original bottom layout?

The default layout file for yii is/view/layout/main. php.
You can directly modify the layout file.

Or you can customize the layout file.
Redefine the following attributes on the Controller
Public $ layout = 'new layout filename ';

You can also disable layout files.
Public $ layout = false;

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.