Runner v. 1.0

Copyright (c) 2008

PHP Developer Documentation

<< Back

Table of contents


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.

Configuring Runner

The config.php file is located in the runner_include directory of your web site. Open up ./runner_include/config.php and it should look something like this:

/* 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');
Here you can change the sessisary varibales to fit your site.

Starting Runner

Starting Runner is another quite easy process. Runner includes a startup file that preforms some of the work for you. Simply include page_setup.php 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.

//Configure All Defines and etc. require("runner_include/page_setup.php"); $runner = new Template(TEMPLATE_DESIGN);

Setting Varibales

Varibales are set by running the Runner function SetData([name], [value]). The only parameters SetData() takes are the name of the varibale to set, and the value to set it to. Value may be an array.


$runner->SetData("name", "John");

$runner->SetDate("colors", array("Red", "White", "Blue") );

$runner->SetDate("food", array("Pizza" => "Good", "Greens", "Bad") );

Printing the Page

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 PrintPage() function. The only argument of the PrintPage() function is the template file to print. The file reference is relitive to the template's directory.




All of the info above culminates into the following example.

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'); Logo