Skip to content

Pages and Recognizers

splitice edited this page May 3, 2012 · 1 revision

Recognizers (Router)

A page recognizer is a class that routes requests to the appropriate PageHandler. Page Recognizers must implement the Web\PageRecogniser\IPageRecognise interface. To make creation of Recognizers faster a few abstract templates have been provided to allow routing based on simple rules. An example of the Standard Template is below.

class Listings extends Templates\Standard {
	static $match = array(
		'/archive/%(month)d/%(year)d'=>'\\Web\\Pages\\Listing',
		'/' => '\\Web\\Pages\\Listing'
	);
}

Page Handlers (Controller)

<?php
namespace Web\Pages;

class Listing extends PageHandler\HTMLPageBase {
	function __construct($data = array()){

	}
	function Title($part = null){
		return parent::Title('OMG it works');
	}
	function GET() {
		//...
		return new ContainerTemplate('index');
	}
}
Clone this wiki locally