Here's the code that went into the links page, as used in the current state of this php system. It consists of the .php controller, the .html template file, and the .css style sheet, thusly:
( php ) ✂
<?php
include( '.Controller.php' );
class Control extends Controller {
function __construct() {
parent::__construct();
$this->log( 'new WebPage', 'HyperJeff Blog Lynks of Olde' );
$page = new WebPage( 'HyperJeff Blog Lynks of Olde' );
$links = new Table( 'links', 'blog' );
foreach( $links->each() as $link ) {
$dateParts = split( ' ', $link['created'] );
$page->setMultipleFieldsForTemplate( 'links', array(
'linkDate' => $dateParts[0], // ex: "2006-12-07"
'linkTitle' => $link['title'],
'linkURL' => $link['url'],
'linkComment' => $link['comment'],
'linkCommentSpot' => ($link['comment'] ? '' : ' '),
));
}
print $page->fullPage();
}
}
new Control();
?>
1 <?php 2 include( '.Controller.php' ); 3 4 class Control extends Controller { 5 6 function __construct() { 7 parent::__construct(); 8 $this->log( 'new WebPage', 'HyperJeff Blog Lynks of Olde' ); 9 $page = new WebPage( 'HyperJeff Blog Lynks of Olde' ); 10 $links = new Table( 'links', 'blog' ); 11 12 foreach( $links->each() as $link ) { 13 $dateParts = split( ' ', $link['created'] );
The Table object automatically makes available all fields of the table, so things like 'title' and 'url' for the link are just read off the fields in the table "links" in the database "blog". The $this->log line is for the logging system, the output of which is shown at the bottom.
The template allows the controller to suck in everything between <field: links> and <\field: links> and iteratively populate the subfields and then replace the block with the resulting sum.