I want to develop a plugin to change the Friends page from one sidebar to a 3 colume layout. Can it be done because there's no Friends plugin?
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.
- Juho Jaakkola@juho.jaakkola
Juho Jaakkola - 0 likes
- Burgs@burgs
Burgs - 0 likes
- Burgs@burgs
Burgs - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Juho Jaakkola@juho.jaakkola
Juho Jaakkola - 0 likes
- Burgs@burgs
Burgs - 0 likes
- Burgs@burgs
Burgs - 0 likes
- Juho Jaakkola@juho.jaakkola
Juho Jaakkola - 0 likes
- Burgs@burgs
Burgs - 0 likes
You must log in to post replies.It is possible. Create a plugin that does the following:
Unregister the default ''friends" page handler and register your own:
Copy the contents of the original friends_page_handler() found in engine/lib/users.php to your own page handler.
Also copy the file pages/friends/index.php to your plugin.
Then change the paths in the page handler so that they are pointing to the index.php that you just copied:
Then in the index.php change this:
To this:
And now you should have the page with one main column and two sidebars. You can pass content to the left sidebar in index.php with:
The two_sidebar is one of the default layouts in Elgg. If it's not what you are looking for you can create your own layout instead. Your own layout becomes available to the elgg_view_layout() function if it is placed in directory views/default/page/layouts/.
Thanks JJ very concise and perfectly pitched to my current level. Will be back with my progress.
When I click on Friends I get an internal server error 500, here's my start.php code and I copied pages/friends/index.php to mod/mytheme/pages/friends/index.php, can anyone see where I've gone wrong...
<?php
register_elgg_event_handler('init','system','mytheme_init');
function mytheme_init() {
// Replace the default friends page
elgg_unregister_page_handler('friends');
elgg_register_page_handler('friends', 'mytheme_friends_page_handler');
}
function mytheme_friends_page_handler($page_elements, $handler) {
elgg_set_context('friends');
if (isset($page_elements[0]) && $user = get_user_by_username($page_elements[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 'friends':
require_once(dirname(dirname(dirname(__FILE__))) . "/mytheme/pages/friends/index.php");
break;
case 'friendsof':
require_once(dirname(dirname(dirname(__FILE__))) . "/pages/friends/of.php");
break;
default:
return false;
}
return true;
}
look first into your apache logs to see exactly what is going on;-O
@Burgs
Yep, the fastest way to see what exactly is wrong is to check the apache error log. (Supposing that you have access to it.)
Oh, and code in messages is much more readable if you but it inside a blockquote and also spend some time to nest it with four spaces where needed:
You can make line breaks with Shift + Enter. (Whereas Enter starts a completely new paragraph.)
@Juho J... I've been wondering how that was done. Just requested access to the logs.
Does this tell you anything. I've checked the file and it's on the server. I uploaded an unedited copy of index.php but still the same 500 error
It says "No such file or directory" so there has to be something wrong with the path to the index.php file. As you look at the path you see that the mod directory is missing:
/home/sites/mytestsite.com/public_html/elgg/mod/mytheme/pages/friends/index.php
Instead of calling the file with:
It might be better to call it with this:
Function elgg_get_plugins_path() always gets the correct plugin directory so you don't have to use dirname(__FILE__) for that.
@Juho J... That works, well done. I owe you a beer.