registerURI is a part of the Jojo plugin API, and allows plugins to add their own custom URI formats.

registerURI replaces (now deprecated) as of the beta1 release.

Capturing URIs - program flow

All page requests in Jojo are send to index.php - index.php must decide which plugin to send the request to for processing.

Jojo will work through all installed plugins until a plugin indicates that it wants control of the request.
If no plugin wants the request, Jojo will try to match against a page in the database. If no match is found, a 404 error is returned.

Do I need to capture URIs?

If your plugin needs a special URL format, and is spread across several pages, it probably needs this.
The following standard plugins, amongst others, make use of this feature.
  • jojo_article
  • jojo_forum
  • jojo_gallery3
  • jojo_faq
  • jojo_tags
  • jojo_googleverification


The gallery3 plugin uses custom URIs in the following format.

As you can see, 2 formats of URI are acceptable for this plugin. The first is an example of basic formating which we will discuss in a moment, it includes a galleryid (34). The second format is especially coded in the plugin to work.

The plugin needs to register the URI format with Jojo so it can take control of any requests that come to these URIs. This is done with the plugins api.php

Basic formatting

Jojo::registerURI("gallery/[id:integer]/[string]", 'JOJO_Plugin_Jojo_gallery3');

Call Jojo::registerUri with 2 arguments. The first is the format you wish to capture, and the second is the plugin class to send the request to.



The above example demonstrates 3 different parts to make up the URI, separated by a forward slash "/".


Match a URI starting with "gallery" literally.


Then, match an integer (0-9). If a match is made, save the value into a GET variable, $_GET['id'].


Then, match a string, being alphanumeric characters, dashes and underscores. Matches will not be made on spaces or other special characters. Because no variable name was specified, not GET variable will be set. In this case, the string is not required for the plugin to work.

Variable types

  • "string" means alphanumeric characters, dashes and underscores.
  • "integer" means characters 0-9 only.
  • "phrase" means alphanumeric characters, dashes and underscores, and spaces.
  • Anything else is considered to be a regular expression or regex. These can be as complicated as you need the to be. We use RegexBuddy to make dealing with Regexes easier (aff).

Complex example

Our Google Verification plugin makes use of a regex to match against URIs such as google487f41eac1c4595a.html - the format for Google's webmaster tools verification file.

This will match a URI starting with "google" then 16 characters of hexadecimal, followed by ".html". If a match is made, $_GET['filename'] is set so the plugin can access the name of the file that was matched.