This article mainly introduced the Zend Framework basic page layout method, combined with the example form analysis the Zend Framework page layout Basic steps and the related setting skill, needs the friend can refer to the next
This example describes the Zend Framework basic page Layout method. Share to everyone for your reference, as follows:
The Zend Framework's page layout module--zend_layout--can be used either with MVC or alone. This article discusses only the scenarios that are used with MVC.
1. Layout script
Create a layouts folder under Application/views. The main layout script layout.phtml code is as follows:
<?php echo $this->doctype (' xhtml1_strict ')? >
In addition to layout.phtml, you also need to write header.phtml,leftcolumn.phtml,footer.phtml, as well as files such as Main.css.
The Zend Framework document uses a single view to represent the application of the page layout.
2. Set Page layout
Setting the page layout under MVC is simple, edit html/index.php, and add the following two lines of code:
/** Setup layout */require_once ' zend/layout.php '; Zend_layout::startmvc ($rootPath. '/application/views/layouts ');
Note: After starting the page layout, you need to adjust the existing pages to remove unwanted HTML elements such as
Changing the layout of the page is also simple, just using the following code in the controller:
$this->_helper->layout->setlayout (' new_layout ');
If a controller uses the same page layout for all actions, it can be set by the controller's initialization function:
Public Function init () {parent::init (); $this->_helper->layout->setlayout (' new_layout ');}