Menu issue

Elgg 2.3.13
 
I'd like to make some changes to the 'title' menu (the code below). It works well with 'menu:owner_block'. However, with 'menu:title' I receive an error:
Fatal error:  Call to a member function getType() on null
Also 'title' menu which is used by many plugins is not found in: mySite.com/admin/develop_tools/inspect?inspect_type=Menus.
 
Please advise.
Thank you
 
 
elgg_register_plugin_hook_handler('register', 'menu:title', 'title_menu_handler');


function title_menu_handler($hook, $type, $items, $params) {

       $owner = $params['entity'];

      register_error($owner->getType());// only for testing

      if($owner){

         if ($owner->getType() == 'group') {

             foreach ($items as $key => $item) {

               // do something

            }

       }

        return $items;

     }
   
 
 
 
  • In the title menu there isn't necessarily an 'entity' in params, that's the error.

    Also 'title' menu which is used by many plugins is not found in the developer tools

    That's because in order to show information there we have to fake some menu's but the title menu has to many variables on order to fake correctly.

    Lot's of menu items are dependent on page owner, context or something else.