Prev | Current Page 691 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

This controller is displayed in Listing 24-3.
Listing 24-3. The AboutController Controller (AboutController.php)
// Load the Zend_Controller_Action class
require_once('Zend/Controller/Action.php');
class AboutController extends Zend_Controller_Action
{
// Accessed through http://www.example.com/about/
public function indexAction()
{
$this->view->title = "About Our Chess Club";
}
// Accessed through http://www.example.com/about/you/
public function youAction()
{
// Page title
$this->view->title = "About You!";
CHAPTER 24 ?–  MVC AND THE Z END F RAMEWORK 615
// Retrieve the user's IP address
$this->view->ip = $_SERVER['REMOTE_ADDR'];
// Retrieve browser information
$this->view->browser = $_SERVER['HTTP_USER_AGENT'];
}
}
?>
Creating the Views
Next, create the views that correspond to these three actions: one for the home page, one
for the /about/ page, and one for the /about/you/ page. Place the homepage view in
the directory /application/modules/default/views/scripts/index/, and the other
two in /application/modules/default/views/scripts/about/. These views are presented
in Listings 24-4, 24-5, and 24-6, respectively. Each of these views is intended to demonstrate
different facets of the behavior of views.
Listing 24-4. The index.phtml View
echo $this->render('header.phtml');
?>


Welcome to our Chess Club's Web site! We're a bunch of chess enthusiasts
who travel the globe in search of worthy opponents.


Pages:
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703