Media website professional
ZendFramework, Php & Mysql, Jquery, javascript, Css, Html...
Using Zend_Layout with the Zend Framework MVC
simple example of zend_layout.
First we define some defined default.
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(dirname(__FILE__)) . '/application')); define('CONFIG_PATH', realpath(APPLICATION_PATH . '/configs')); define('LAYOUT_PATH', realpath(APPLICATION_PATH . '/layouts')); define('PUBLIC_URL', '/zftut/public');
The next, we create LayoutController.
LAYOUT_PATH . '/scripts', 'layout' => 'index', 'viewSuffix' => 'phtml' ); Zend_Layout::startMvc($options); } public function mainAction(){ $options = array( 'layoutPath'=> LAYOUT_PATH . '/scripts', 'layout' => 'main', 'viewSuffix' => 'php' ); Zend_Layout::startMvc($options); } public function changeLayoutAction() { $this->_helper->layout->setLayout('main2'); } public function disableAction(){ $this->_helper->layout->disableLayout(); } public function noViewAction(){ $this->_helper->viewRenderer->setNoRender(); } public function placeHolderAction(){ $this->view->placeholder('Zend_Layout')->foo = ' This is a test'; $this->_helper->layout->setLayout('index'); } }
File layout in application\layouts\scripts\index.phtml
doctype() ?> headTitle() ?> headMeta() ?> headLink() ?> headScript() ?>
Layout.phtml
layout()->content ?> layout()->foo;?>
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment