However, because this isn??™t always possible, you can use the setBaseUrl() method
to override the front-end controller??™s default behavior. See the Zend Framework
documentation for more information.
Creating the Controllers
Next, create two controllers, namely IndexController.php and AboutController.php.
These controllers should be placed in the directory application/modules/default/
controllers. First, create the default controller class (IndexController.php), which
defines the action that occurs when the Web site??™s home page is requested (for the sake
of consistency throughout the remainder of this chapter, http://www.example.com/ is
referenced as the target domain). This script is shown in Listing 24-2.
Listing 24-2. The IndexController Class (IndexController.php)
// Load the Zend_Controller_Action class
require_once('Zend/Controller/Action.php');
class IndexController extends Zend_Controller_Action
{
614 CHAPTER 24 ?– MVC AND THE Z END F RAMEWORK
// Accessed through http://www.example.com/
public function indexAction()
{
$this->view->title = "Welcome to Our Chess Club Web Site!";
}
}
?>
This script creates a view property named title that will be used to assign the Web
page??™s title.
Finally, create one more controller, AboutController.php, intended to display
information pertinent to the Web site??™s purpose and, for sake of demonstration,
some information about the visiting user.
Pages:
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702