Chapter one provided a basic introduction to how a controller's action method displays its output in a view script of the same name. To review:
Given the URL http://localhost/blog/read/1 ...
-
blog is the controller
-
read is the action
-
1 is a parameter (multiple params may be passed)
This maps to ...
-
Acme_App_Blog::actionRead(1)
inSYSTEM
/source/acme/Acme/App/Blog.php
Which outputs to ...
-
SYSTEM
/source/acme/Acme/App/Blog/View/read.php
Solar expects to find view scripts in predefined locations. The default directory structure for the Acme vendor with a single blog application looks like the following:
Acme/ App/ Blog/ Layout/ Locale/ Public/ View/ Blog.php Controller/ Bread/ Layout/ Locale/ Public/ View/ Page/ Layout/ Locale/ Public/ View/ Bread.php Page.php Model/ Sql/ Filter.php
It should be reasonably obvious from this structure where views and layouts are
expected to be found. The blog application expects to find its views and layouts
in
and SYSTEM
/source/acme/Acme/App/Blog/View
respectively. That is straighforward enough, however; if you open the
SYSTEM
/source/acme/Acme/App/Blog/Layout
file in your favorite editor, you will notice that
the SYSTEM
/source/acme/Acme/App/Blog.phpAcme_App_Blog
class extends
Acme_Controller_Page
. This is important because it influences
the class stack; the hierarchy where Solar looks
for files. In this case, Solar first looks for views in
,
and if it doesn't find the required view there, it then looks in
SYSTEM
/source/acme/Acme/App/Blog/View
.
The same goes for layouts. Keep this in mind as you proceed through this chapter.
SYSTEM
/source/acme/Acme/Controller/Page/View