Location: PHPKode > projects > Runner > docs/page_maker.html
<!--
 **********************************************************************
 *  Copyright 2008
 * 
 *  This file is part of Runner.
 * 
 *  Runner is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  Runner is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with Runner.  If not, see <http://www.gnu.org/licenses/>.
 *
 ********************************************************************** 
*/
-->

<html>
<head>
<title>PHP Developer Documentation</title>


<style type="text/css">

@media all {
	body {
		font-family: Verdana, Arial, Helvetica, Garamond, sans-serif;
		text-align: left;
		background-color: #FFF;
		font-size: 90%;
		margin: 5px;
		padding: 10px 5px 10px 5px ; 
	}
	a:link {color: #993333; text-decoration: underline}
	a:visited {color: #993333; text-decoration: underline}//#006699;
	a:active {color: #FF3300; text-decoration: underline}
	a:hover {color: navy; text-decoration: underline}
	h1 { font-family: Comic, Lithograph, Arial; color:black; text-align: left; font-size: 180%; font-weight: 600; display: inline;}
	h2 { font-family: Comic, Lithograph, Arial; color:black; text-align: left; font-size: 160%; font-weight: bold}
	img, table {border-width: 0px}
	
	h3 {font-family: Comic, Lithograph, Arial; color:black; text-align: left; font-size: 120%}
	p, td {font-family: Verdana, Arial, Helvetica, Garamond, sans-serif; font-size: 90%; text-align: left; vertical-align: top;}
		
	th {
		font-family: Verdana, Arial, Lithograph, Helvetica, sans-serif;
		text-align: left;
		font-size: 90%;
		font-weight: bold;
		vertical-align:top;
	}
	
	code {
		font-family: "Courier New", Courier, mono;
		font-size: 100%;
		white-space: pre;
	}
	blockquote {
		width:800px;
		background-color:#DFDFDF;
		border:1px dashed #4D4D4D;
		padding:10px;
	}
table.sample {
	border-width: 1px 1px 1px 1px;
	border-spacing: 2px;
	border-style: solid solid solid solid;
	border-color: gray gray gray gray;
	border-collapse: separate;
	background-color: rgb(255, 245, 238);
}
table.sample th {
	border-width: 1px 1px 1px 1px;
	padding: 2px 2px 2px 2px;
	border-style: none none solid none;
	border-color: black black black black;
	background-color: rgb(250, 240, 230);
	-moz-border-radius: 0px 0px 0px 0px;
}
table.sample td {
	border-width: 1px 1px 1px 1px;
	padding: 2px 2px 2px 2px;
	border-style: none none none none;
	border-color: black black black black;
	background-color: rgb(250, 240, 230);
	-moz-border-radius: 0px 0px 0px 0px;
}	
}
</style>
</head>

<body>

<img src='images/runner_logo.png' width='35px' style='margin:0px;padding:00px;'><span style='float:left;'><h3>Runner v. 1.0</h3></span><br><br><span style='float:right;'>Copyright (c) 2008</span><br>
<br>
<hr>

<h1>PHP Developer Documentation</h1><br>
<a href='index.html'><< Back</a>

<h2>Table of contents</h2>
<ul>
	<li><a href='#intro'>Introduction</a></li>
	<li><a href='#configure'>Configuring Runner</a></li>
	<li><a href='#starting'>Starting Runner</a></li>
	<li><a href='#setting_vars'>Setting Varibales</a></li>
	<li><a href='#printing'>Printing the Page</a></li>
	<li><a href='#example'>Example Page</a></li>
</ul>

<h2><a name='intro'></a>Introduction</h2>
<p>There really is not much to do as far as the PHP side of Runner goes, 
it is basically a 'set and forget' program. Once you edit the website's 
configure files, and create the php pages, you are done. For once the 
designers will actually have more to do than the coders. 
<p>

<h2><a name='configure'></a>Configuring Runner</h2>
<p>The <code>config.php</code> file is located in the <code>runner_include</code> 
directory of your web site. Open up <code>./runner_include/config.php</code> and it should look 
something like this:<br>
<blockquote>
<code>	/*	Tells the pages we have been configured  		*/
define(CONFIG, TRUE);
define(DEBUG, 'true');

	/*          Directory root 
	 * (directory containing index.php) 				*/
define(ROOT_DIR, "./");
define(WEBSITE, "http://localhost/");

	/*        Set the current template Design 			*/
define(TEMPLATE_DESIGN, "templates/slim.tpl");	

	/* 	Set Time Zone 	*/
date_default_timezone_set('America/New_York');

	/* 	Date And Time Format						*/
//Moth day, year (Jan 1st 2009)
define (DATE_FORMAT, "M jS, o");
//Hour : Minute when (12:20 am)
define (TIME_FORMAT, "g:i a");

	/* 	Template cache system						*/
// Cache compiled pages
define(CACHE_RUNNER, 'no');
//Relitive to root diectory
define(CACHE_DIR, './cache');
//Extention of cache files
define(CACHE_EXT, '.cache');
//Time in seconds to keep cached page (time)
define(CACHE_TIME, '600'); // 10 min = 600; 1 day = 86400; 2 days = 172800 

	/* 	SQL Connection 							*
	 * 
	 * Not used in Runner 
	 * but included for convinience 					*/
define (DB_SERVER   , 'localhost');
define (DB_USERNAME , 'username');
define (DB_PASSWORD , 'password');
define (DB_PREFIX   , 'db_');
define (DB_MAIN_DB  , 'website');
</code>
</blockquote>
Here you can change the sessisary varibales to fit your site. 
</p>

<h2><a name='starting'></a>Starting Runner</h2>
<p>Starting Runner is another quite easy process. Runner includes a 
startup file that preforms some of the work for you. Simply include 
<code>page_setup.php</code> to include the other nessisary file, and 
start a session. After this the rest is just setting varibales and printing the page.
Below is an example of all the setup lines, you would need to include.
<blockquote>
<code>//Configure All Defines and etc.
require("runner_include/page_setup.php");

$runner = new Template(TEMPLATE_DESIGN);
</code>
</blockquote>

<h2><a name='setting_vars'></a>Setting Varibales</h2>
<p>Varibales are set by running the Runner function <code>SetData([name], [value])</code>. 
The only parameters <code>SetData()</code> takes are the <code>name</code> of 
the varibale to set, and the <code>value</code> to set it to. <code>Value</code> may be an array. 
<br>
<h3>Example:</h3>
<blockquote>
	<code>$runner->SetData("name", "John");</code><br><br>
	<code>$runner->SetDate("colors", array("Red", "White", "Blue") );</code><br><br>
	<code>$runner->SetDate("food", array("Pizza" => "Good", "Greens", "Bad") );</code><br>
</blockquote>

<h2><a name='printing'></a>Printing the Page</h2>
<p>Once all the varibales have been set acordingly, the only thing left 
is to print the page. This is just a simple matter of calling the 
<code>PrintPage()</code> function. The only argument of the 
<code>PrintPage()</code> function is the template file to print. The 
file reference is relitive to the template's directory.
<br>
<h3>Example:</h3>
<blockquote>
	<code>$runner->PrintPage('index.tpl');</code><br>
</blockquote>


<h2><a name='example'></a>Example</h2>
<p>All of the info above culminates into the following example.</p>

<blockquote>
<code>require("runner_include/page_setup.php");
$runner = new Template(TEMPLATE_DESIGN);

$runner->SetData("name", "John");
$runner->SetDate("colors", array("Red", "White", "Blue") );
$runner->SetDate("food", array("Pizza" => "Good", "Greens", "Bad") );

$runner->PrintPage('index.tpl');
</code>
</blockquote>
Return current item: Runner