Developing plugin pages
From KnowledgeTree Document Management Made Simple
Plugins can introduce new pages to KnowledgeTree within their own location (defaulting to /plugin.php/plugin.namespace/...).
This is necessary only when:
- The page isn't tied to a particular document - use a document action instead
- The page isn't tied to a particular folder - use a folder action instead
- The page isn't an administration page - use an administration page instead
For example, a page listing the subscriptions for a user would be a plugin page. A page displaying RSS feeds would also be a plugin page.
The page is a dispatcher, and generally extends the KTStandardDispatcher class:
register_once(KT_LIB_DIR . '/dispatcher.inc.php');
class KTSubscriptionManagePage extends KTStandardDispatcher {
...
}
As a dispatcher, the page needs to implement the do_main method.
function do_main() {
return "Some text";
}
The page is registered with the plugin to which it belongs:
require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php');
$oPlugin =& $oRegistry->getPlugin('ktstandard.subscriptions.plugin');
$oPlugin->registerPage('manage', 'KTSubscriptionManagePage', __FILE__);
- The first parameter to registerPage is the path relative to the root of the plugin's page space.
- The second parameter is the class for the page
- The third parameter is the location where the class is implemented.
In the case above, the page will be accessible at this URI relative to the KnowledgeTree install:
/plugin.php/ktstandard.subscriptions.plugin/manage
The correct way to get this URI is from the plugin:
require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php');
$oPlugin =& $oRegistry->getPlugin('ktstandard.subscriptions.plugin');
$url = $oPlugin->getPagePath('manage');
del.icio.us
reddit

