Now let's create our home page. CD back to the top of the modules directory and run:
$ phocoa createModule
phing -f /Users/alanpinstein/dev/sandbox/phocoa/phocoa/phing/build.xml -Dusing.phocoa.make=true -Dphocoa.pwd=/Users/alanpinstein/dev/sandbox/blog/blog/modules -Dphocoa.dir=/Users/alanpinstein/dev/sandbox/phocoa/phocoa -Dphocoa.project.name=blog -Dphocoa.project.dir=/Users/alanpinstein/dev/sandbox/blog/blog createModule
Buildfile: /Users/alanpinstein/dev/sandbox/phocoa/phocoa/phing/build.xml
phocoa > prepareGeneral:
[echo] PHOCOA framework base dir at: /Users/alanpinstein/dev/sandbox/phocoa/phocoa
phocoa > prepareProject:
[echo] 1
[php] Evaluating PHP expression: $_ENV['_']
[echo] PHOCOA project dir at: /Users/alanpinstein/dev/sandbox/blog/blog
[realpathexpandhome] Resolved /Users/alanpinstein/dev/sandbox/blog/blog/.. to /Users/alanpinstein/dev/sandbox/blog
[echo] PHOCOA project container dir at: /Users/alanpinstein/dev/sandbox/blog
[property] Loading /Users/alanpinstein/dev/sandbox/blog/blog/conf/build.properties
[property] Unable to find property file: /Users/alanpinstein/dev/sandbox/blog/blog/conf/build.properties... skipped
phocoa > createModule:
Module name: pages
Default page [blank for none]: home
[exec] Executing command: /opt/local/bin/php /Users/alanpinstein/dev/sandbox/phocoa/phocoa/framework/createModule.php pages home 2>&1
[exec] Writing pages/pages.php
[exec] Done building module pages!
[exec] Writing home.tpl
[exec] Writing home.yaml
[exec] Done!
BUILD FINISHED
Total time: 2.8443 seconds
Now that we have a home page, we want this page to actually load
when we click the home link! To do this, we adjust the
defaultInvocationPath on our
WFWebApplicationDelegate object, in
classes/MyWebApplicationDelegate.php:
function defaultInvocationPath()
{
return 'pages/home';
}
Now we can click on our Home link and will be taken to our newly created home page.
Of course, our home page is currently empty. We want it to have a little introduction and then list the 10 most recent posts.
First let's add the list of the recent posts. Since we have
already created a module to do exactly that, we can use the convenient
UI widget WFModuleView to include that
information. Edit the home.yaml file as
follows:
topPosts:
class: WFModuleView
properties:
invocationPath: 'blogview/list'
Now, let's create the home page template:
<h1>Welcome to the PHOCOA blog!</h1>
{WFView id="topPosts"}
Reload the home page, and you'll see the finished product.
Congratulations! You've now seen all of the steps involved in creating a basic web application in PHOCOA.