3.4 3.3
Jump to table of contents

Add Custom Page

You may want your plugin to add a new page to the application. This may be a separate settings page or editorial dashboard on the backend, or a new public page on the reader-facing website.

A generic plugin can do this by hooking into the request lifecycle and loading its own PageHandler.

You should understand the Request Lifecycle and be familiar with the application architecture, especially Handlers, before proceeding.

The example below shows a request to a custom page.

class TutorialExamplePlugin extends GenericPlugin {
	public function register($category, $path, $mainContextId = null) {
		$success = parent::register($category, $path, $mainContextId);
		if ($success && $this->getEnabled()) {
			HookRegistry::register('LoadHandler', array($this, 'setPageHandler'));
		return $success;
	public function setPageHandler($hookName, $params) {
		$page = $params[0];
		if ($page === 'tutorialexample') {
			define('HANDLER_CLASS', 'TutorialExamplePluginHandler');
			return true;
		return false;
class TutorialExamplePluginHandler extends Handler {
	public function index($args, $request) {
		$plugin = PluginRegistry::getPlugin('generic', 'tutorialexampleplugin');
    $templateMgr = TemplateManager::getManager($request);
    return $templateMgr->display($plugin->getTemplateResource('example.tpl'));

The TutorialExamplePluginHandler can have more than one op and supports all the capacities of a regular PageHandler.

Read about the authorization framework to keep your private pages secure.

View more examples.