Activity

  • Sachin replied on the discussion topic How can i remove menu item from entity menu
    Thanks @rivervanrain for taking time, much appreciated. I have just made this to work. The 2nd approach worked for me. Thanks a lot . view reply
  • Sachin added a new discussion topic How can i remove menu item from entity menu in the group Elgg Technical Support
    I am simply unable to remove the menu items from the entity menu. I want to remove the access, like and delete menus from the blog-listings(example.com/blog/all) to show up. I only need blog title, sub-text, excerpt and the entity-menu(without...
    • On all site

      For Likes

      elgg_unregister_plugin_hook_handler('register', 'menu:entity', 'likes_entity_menu_setup');

      For Delete and Access

      elgg_unregister_plugin_hook_handler('register', 'menu:entity', 'elgg_entity_menu_setup');

      elgg_register_plugin_hook_handler('register', 'menu:entity', 'my_entity_menu_setup');

       

      function my_entity_menu_setup($hook, $type, $return, $params) {
          if (elgg_in_context('widgets')) {
              return $return;
          }
          
          $entity = $params['entity'];
        
          $handler = elgg_extract('handler', $params, false);

         if ($entity->canEdit() && $handler) {
              // edit link
              $options = array(
                  'name' => 'edit',
                  'text' => elgg_echo('edit'),
                  'href' => "$handler/edit/{$entity->getGUID()}",
                  'priority' => 100,
              );
              $return[] = ElggMenuItem::factory($options);
          }

          return $return;
      }

       

      On Blogs only

      Another way:

      elgg_register_plugin_hook_handler('register', 'menu:entity', 'blog_setup_entity_menu_items');

      function blog_setup_entity_menu_items($hook, $type, $value, $params) {
          $handler = elgg_extract('handler', $params, false);
          if ($handler != 'blog') {
              return $value;
          }

          foreach ($value as $index => $item) {
              $name = $item->getName();
              if ($name == 'access' || $name == 'delete' || $name == 'likes') {
                  unset($value[$index]);
              }
          }

          $entity = $params['entity'];

         if ($entity->canEdit() && $handler) {
              // edit link
              $options = array(
                  'name' => 'edit',
                  'text' => elgg_echo('edit'),
                  'href' => "$handler/edit/{$entity->getGUID()}",
                  'priority' => 100,
              );
              $value[] = ElggMenuItem::factory($options);
          }

          return $value;
      }

    • Thanks @rivervanrain for taking time, much appreciated. I have just made this to work. The 2nd approach worked for me. Thanks a lot .

  • Sachin joined the group General Discussion
  • Sachin joined the group Elgg Technical Support
  • Sachin joined the group India Community
  • Sachin has a new avatar
    Sachin
  • Sachin joined the group Beginning Developers

Friends

No friends yet.

Send private message

You must be logged in to send a private message.

Group membership