How Do You Work With Diverse Layouts in Your Application Using Yii2?
In this article, we’ll show you how to create various layouts for action views in your app. We assume, for example, that our application’s pages will employ three alternative layouts: A one-column layout has only the main content area; a two-column layout has a left sidebar displaying portlets and the main content area; and a three-column layout has a left sidebar displaying portlets, the main content area, and a right sidebar displaying some context information. Creating Layouts The 960 Grid System is used to simplify the CSS design. Because all three layouts have the same header and footer sections, we start with the primary layout, which will be the parent of the three. All of these layout files are kept in the protected/views/layouts folder. Making Use of Layouts The layout of a page (produced by calling [CController::render]) is primarily governed by two properties: [CWebApplication::layout] and [CController::layout], as we know. The former specifies the global layout for al...