Moving on with the tutorial..
Now we are going to do a little more with the zones and acutally make this application usuable...
First step is that we want to make a landing page that links to our different pages and zones.
Lets create a new file called menu.tpl and place it in app_dir/templates/default/ (the standard location for templates).
place the following contents into menu.tpl
{include file="head.tpl"} <body> <h1>Our Menu</h1> <a href="{$BASE_HREF}/email/send">Send An Email</a><br> </body> </html>
Notice we are doing a gui include. By including an already existing tpl file that is packaged with the skeleton we will load up all the javascript we will use in the next section. Of course since the skeleton is now your application you can modify it to do whatever you like.
We are going to change the pageDefault function of zone_default (the one we used in the last section of this book) where we just put the hello world to now display this file instead. The pageDefault function inside of zone_default should look as follows:
function pageDefault($inPath) { global $gui; $gui->display("menu.tpl"); }
Now lets create our very own zone... we will call it email. The easiest way to do this is to copy the Template zone_name.php file and call it zone_email.php.
We need to change all references from zone_name to zone_email. A simple search and replace will do it.
Our file should have the following contents:
<? class zone_email extends zone { function zone_email() { //$this->setUrlVarNames(array("Id", "Id")); } function makePath() { return "/name"; } function initZone($inPath) { // do things here that you want to happen on every // request that includes this zone } function initPages($inPath) { // do things here that you want to happen for // every request that ends with a page in this zone, // including posts } function pageDefault($inPath) { global $gui; $gui->display("default.tpl"); } function postDefault($inPath) { // this is for posts, it handles when // forms get submitted. } }
We also need to make sure that our new zone is included. This occurs in the includes.php file. There is a section dedicated to adding Zones... There should already be a couple there just place this line after them .
$zoop->addZone("email");
Notice how we used the zone name, not the file name.
Now in the zone_email.php file we are going to add a new function.
We will call it pageSend. It can be placed anywhere within the class definition. I usually add it to the end.
For the time being we will just put an echo into that function so that we can test everything up till this point.
function pageSend($inPath) { echo("here at pageSend"); }
Now lets fire up our favorite browser and goto our skeleton. Since we are now displaying template in the pageDefault function we should see the output from our menu.tpl.