The first thing we'll need is some content, and I'm going to use the simplest content possible for this example. So I'll create my ContentController.php and then add blank actions for an index plus 5 pages. The code looks like this:
class ContentController extends Zend_Controller_Action
{
  public function indexAction() {}
  public function page1Action() {}
  public function page2Action() {}
  public function page3Action() {}
  public function page4Action() {}
  public function page5Action() {}
}Now that there's some rudimentary content, we'll add a simple layout to the site. Add Zend_Layout to the MVC by adding the following line to your index.php bootstrap file:
    /**
   * Layout helper
   */
   require_once 'Zend/Layout.php';
   Zend_Layout::startMvc();resources.layout.layoutPath = APPLICATION_PATH "/views/layouts"<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>My Site
  <link href="http://www.bluerobot.com/web/layouts/layout1.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="Header">My Site</div>
<div id="Content">
<?php
  // fetch 'content' key using layout helper:
  echo $this->layout()->content;
?>
</div>
<div id="Menu">
  menu goes here
</div>
</body>Happy coding!
 
No comments:
Post a Comment