Zend Framework basic Page Layout Analysis _php instance

Source: Internet
Author: User
Tags zend zend framework

This example describes the basic page layout method for the Zend framework. Share to everyone for your reference, specific as follows:

The Zend Framework's page layout module--zend_layout--can be used with MVC or alone. This article only discusses 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, it is necessary to write header.phtml,leftcolumn.phtml,footer.phtml, as well as main.css files.
The Zend Framework document uses a view to represent the application of the page layout.

2, set the page layout

Setting the page layout under MVC is very 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 you start the page layout, adjust the existing pages to remove unwanted HTML elements, such as

Changing the layout of the page is also simple, just use the following code in the controller:

$this->_helper->layout->setlayout (' new_layout ');

If all of the actions of a controller use the same page layout, you can set it through the controller's initialization function:

Public Function init () {
parent::init ();
$this->_helper->layout->setlayout (' new_layout '); 
}

More interested in Zend related content readers can view the site topics: "The introduction of the Zend Framework frame", "PHP Excellent Development Framework Summary", "Yii framework Introduction and common skills Summary", "thinkphp Introductory Course", "PHP object-oriented Programming Program , "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation Skills Summary"

I hope this article will help you with the PHP program design based on the Zend Framework.

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.