CHALLENGE

Can anyone make the friends page a two_sidebar page without touching the core codes?

  • The code to change the layout from one_sidebar to two_sidebar is found in the core file pages/friends/index.php. No plugin has tackled that. Even river_activity_3C and river_addon haven't made the friends page a two_sidebar page. 

  • Copy the file

    pages\friends\index.php

    In to

    your_theme\pages\friends\index.php

    Then edit it

  • I had tried that before. It didn't work. That's why I have put forward a challenge. 

  • Did you overrided friends_page_handler function in your theme?

    You need set:

        elgg_register_page_handler('friends', 'friends_page_handler');
        elgg_register_page_handler('friendsof', 'friends_page_handler');

    In start.php

     

    Then override function, e.g.:

    function 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("{$CONFIG->path}mod/your_theme/pages/friends/friends.php");
                break;
            case 'friendsof':
              require_once("{$CONFIG->path}mod/your_theme/pages/friends/of.php");
                break;
            default:
                return false;
        }
        return true;
    }

  • I tried that but I got the following error: Fatal error: Cannot redeclare friends_page_handler() (previously declared in C:\xampp\htdocs\sites\elgg-1.8.13\engine\lib\users.php:1070)

  • I would have deactivated the friends functionality if it were a plugin. Elgg, please make the friends feauture a plugin! 

  • You'll need to override this function with your own theme hook : your_theme_friends_page_handler

  • I did that, but again, there is no result. If you have time, can you create such a plugin? 

  • Take it: Custom friends (dumbest Elgg *plugin*) - Just two sidebars on Elgg Friends pages, no more ;)

  • Thank you RvR. My admiration for you. 

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking