URL Handler Registration

Each URL Handler must be registered in configuration storage (Db table “Configuration”) prior to its usage.

For your reference, Vivvo's default URL Handlers are instanced during installation of Vivvo (/installer/index.php. lines 1092-1136).

Registering custom URL Handler

You can register URL Handler using special register_url() register method, which is probably the most convenient and fastest method to register new URL Handler.

Description

bollean register_url (string URL, string PATH_TO_FILE, string URL_HANDLER, string CONTENT_HANDLER);

Example:

$sm =& new vivvo_lite_site();
$um =& $sm->get_url_manager();
$um->register_url('archive', 'lib/vivvo/url_handlers/archive.php', 'archive_url_handler', 'archive_content_handler');

Un-Registering custom URL Handler

You may un-register the URL Handler using unregister_url(); method.

Example:

$sm =& new vivvo_lite_site();
$um =& $sm->get_url_manager();
$um->unregister_url('archive');

Registering URL Handler directly in Configuration SQL table

Alternatively, you can register the Url Handler directly in “Configuration” database table, without using register_url() method.

$query = "INSERT INTO `".$tbl_prefix."Configuration` 
(`id`, `variable_name`, `variable_property`, `variable_value`, `module`, `domain_id`, `reg_exp`)
	VALUES 
(...)

URL Handler registration elements

Each registered URL Handlers has two or three elements/rows in Configuration table

File:

Parameter name Value Description
variable_namestring the name for the URL i.e. “archive”
variable_property'file' distinguishes what you actually register
variable_valuestring value for the file param, path to PHP URl handler file i.e. “lib/vivvo/url_handlers/archive.php”
module'modules' module type, i.e. “url_modules”
domain_idinteger for future enhancements, not used at this point

URL Handler:

Parameter name Value Description
variable_namestring the name for the URL i.e. “archive”
variable_property'url_handler_function' distinguishes what you actually register
variable_valuestring name of URL Handler function i.e. “archive_url_handler”
module'modules' module type, i.e. “url_modules”
domain_idinteger for future enhancements, not used at this point

Content Handler:

Parameter name Value Description
variable_namestring the name for the URL i.e. “archive”
variable_property'content_handler_function' distinguishes what you actually register
variable_valuestring name of Content Handler function i.e. “archive_content_handler”
module'modules' module type, i.e. “url_modules”
domain_idinteger for future enhancements, not used at this point

You do not need this information if you use register_url() method!

Examples

Example #1: Most convinient and fastest way is to register URL Handler via $site_manager.

$sm =& new vivvo_lite_site();
$um =& $sm->get_url_manager();
$um->register_url('my_url.html', 'my_url.php', 'my_url_url_handler', 'my_url_content_handler');

Example #2: Another way is to register module via SQL directly, i.e. in default Vivvo installer.

(NULL, 'my_url.html', 'file', 'my_url.php', 'url_modules', 1, NULL),
(NULL, 'my_url.html', 'url_handler_function', 'my_url_url_handler', 'url_modules', 1, NULL),
(NULL, 'my_url.html', 'content_handler_function', 'my_url_content_handler', 'url_modules', 1, NULL),
 
devdoc/url_handlers/register.txt · Last modified: 2008/11/20 07:47 by shketuljko
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki