The example in this article describes the basic page layout method of Zend Framework. Share it with everyone for your reference, the details are as follows:
Zend Framework’s page layout module—Zend_Layout—can be used together with MVC or alone. This article only discusses use 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') ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php echo $this->headTitle() ?> <?php $this->headLink()->appendStylesheet("/styles/main.css"); // add more links ... ?> <?php echo $this->headLink() ?> </head> <body> <div id="header"> <?php echo $this->partial('header.phtml') ?> </div> <table> <tr> <td valign=top> <div id="leftcolumn"> <?php echo $this->partial('leftcolumn.phtml') ?> </div> </td> <td valign=top> <div id="content"> <?php echo $this->layout()->content ?> </div> </td> </tr> </table> <div id="footer"> <?php echo $this->partial('footer.phtml') ?> </div> </body> </html>
In addition to layout.phtml, you also need to write header.phtml, leftcolumn.phtml, footer.phtml, and main.css files.
The documentation of Zend Framework uses a view to represent the application of 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 starting the page layout, adjust the existing pages and remove unnecessary html elements, such as
Changing the layout of the page is also very simple, just use the following code in the controller:
$this->_helper->layout->setLayout('new_layout');
If a controller All actions use the same page layout, which can be set through the initialization function of the controller:
public function init() { parent::init(); $this->_helper->layout->setLayout('new_layout'); }
I hope that this article will help everyone use PHP based on the Zend Framework framework. Programming helps.
For more articles related to Zend Framework basic page layout analysis, please pay attention to the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.