Example:
elgg_unregister_page_handler('friends', 'friends_page_handler');
elgg_unregister_page_handler('friendsof', 'friends_page_handler');elgg_register_page_handler('editors','theme_editors_page_handler');
function theme_editors_page_handler($segments, $handler) {
elgg_set_context('editors');
if (isset($segments[0]) && $user = get_user_by_username($segments[0])) {
elgg_set_page_owner_guid($user->getGUID());
}
if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) {
collections_submenu_items();
}
switch ($handler) {
case 'editors':
require_once(dirname(dirname(dirname(__FILE__))) . "/pages/friends/index.php");
break;
default:
return false;
}
return true;
}
Check it on http://weborganizm.com
Ok, thanks to both of you.
I did it exactly like you have suggested it. But my handler is routed to the home page. I suppose that something is wrong with the place I have stored the index.php. I put it to '/mod/myplugin/pages/friends/index.php'. And no matter if I am writing:
require_once(dirname(dirname(dirname(__FILE__))) . "/pages/friends/index.php");
or
require_once(elgg_get_plugins_path() . "myplugin/pages/friends/index.php");
It doesn't route to my index.php. Any hints?
I found the bug. It was the usual copy & paste error. ;-)
I copied parts of the code from the original friends_page_handler() function in /engine/lib/users.php, but used in my plugin_friends_page_handler() function another name for the parameter $segments.
Now it works fine.
Thanks again for your help.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.