FORUMS CLOSED DUE TO SPAM. YOU STILL CAN ADD POST!

Register URLs from plugin

Feed 2 posts, 2 voices

Avatar
13 posts

I request a method for registering URLs from a Plugin. The plugins should have to register the URL each page call, and the URLs should not be saved anywhere, longer than the script runs. A given method of the Plugin class should be called each time the URL get requested. If a user wants to create a page with the same slug, then a error schould be thrown.
I am thinking about creating a RPC Module with two submodules for XML- and JSON-RPC, that notify all other plugins using the Observer.

array() = Plugin::registerUrl($slug,$handler);

Options

$slug: Defines the slug of the Page.
$handler: The name of a method of this class, that handles requests to this URL.

Returns (Example)

TRUE on success.
FALSE if a error occured, e.g. if a page with this slug already exists.

 
Avatar
13 posts

No Feedback?

 
Avatar
180 posts
function some_page_requested($uri) {
	$uri = split('/', $uri);
	if($uri[0] == 'need_url' && (!empty($uri[1]) || !empty($uri[2]))){
		echo "Yeah, I visit /need_url/... Params: {$uri[1]}, {$uri[2]}";
		some_function($uri[1], $uri[2]); // call some_function() when url /need_url/param1/param2
	}
}
Observer::observe('page_requested', 'some_page_requested');

Like this?