A function may be registered to the first element in a URI with the function WebTemplate::registerURIHandler(). The function will then be called whenever a URI begins with the element. The requested URI will be passed to the function.
The function should return true when it handles the URI and false otherwise.
An Example: print "hello back" for any URI which begins with /hello
This code should be within a PHP file in the code directory:
class URIHandler {
public static function sayHello($uri) {
print "hello back";
// return true to say we've handled the request
return true;
}
}
$GLOBALS["WT"]->registerURIHandler("hello", Array("URIHandler", "sayHello"));
now any request to the "hello" URI will print "hello back"
eg:
http://example.com/hello