Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Zend Framework Tutorial

By Lyndon Baptiste
2008-08-13


Actioning Requests

Let's set up two files, make sure things are in order and then we'll get to the discussion. Revisit Figure 1 for a second. In the modules directory, as depicted to the left of the illustration, create a folder and name it "default". In "default" create three folders: one for your controllers, associated models and views. In the "views" folder create a folder named "scripts". The norm is that in the "scripts" folder you will have folders for your views which relate to the name of the controllers nested in the module. Now that this file structure is set up go to the controllers directory. Create a file call IndexController.php and paste following code into it:

<?php
require_once 'Zend/Controller/Action.php';

class IndexController extends Zend_Controller_Action {
public function init() {
$this->initView();
}

public function preDispatch() {

}

public function postDispatch() {

}

public function indexAction() {
$this->render();
}
}?>

Now that's over go to the views directory. Create a file called index.phtml and paste the following code into it:

<p>
Page body from view will be rendered. This corresponds to the content key that was set up in the
associative array with the key 'content'.
</p>

Before you fire up your webserver and make a request go to the layouts directory in the application folder. Create a file called default.phtml and paste the following code:

<html>
<head>
<title></title>
</head>

<body>
<div>
<h1>Page header template here</h1>
</div>
<div>
<?php echo $this->layout()->content; ?>
</div>
<div>
<h1>Page footer template here</h1>
</div>
</body>
</html>

Tutorial Pages:
» Introduction
» The index.php File
» Actioning Requests
» The IndexController
» The View and Layout
» Zend_Form
» CSS Code
» Validating Our Form
» Zend_DB_Table
» Back To The Controller
» Back to Zend_DB_Table
» Putting Zend_Registry and Zend_Cache Into Perspective
» Conclusion


Related Tutorials:
» Port Scanning and Service Status Checking in PHP
» Web Database Access from Desktop Applications
» CubeCart 3.0 Installation and Configuration
» PHP Site Search Made Easy
» Installing and Configuring Drupal 6.1
» Desktop Application Development with PHP-GTK

Ask A Question
characters left.