Processing a URI

A function may be registered to read in a URI and convert it to another URI before WebTemplate decides which page to display.  The function is registered with WebTemplate::registerURIProcessor. The function should return the new URI to be handed to WebTemplate, or it should output content and exit.

Example

class URIProcessor {

  public static function processURI($uri) {
    $uriParts = explode("/", $uri);
    // if the uri begins with "article", display the blog page
    if(count($uriParts) > 0 && $uriParts[0] == 'article') {
      return "blog";
    }
    // no change needed to the URI, so return the original URI
    return $uri;
  }
}

$GLOBALS["WT"]->registerURIProcessor(Array("URIProcessor", "processURI"));