Display count of Friends and Groups for Profile

How can to display counts of Friends, Friends of and Groups on the User's Profile for Elgg 1.8

How can to display counts of Friends, Friends of and Groups on the User's Profile for Elgg 1.8

Open the file

elgg\mod\profile\views\default\profile\owner_block.php

After this code

$content_menu = elgg_view_menu('owner_block', array(
'entity' => elgg_get_page_owner_entity(),
'class' => 'profile-content-menu',
));

Add this code

$content_menu .= elgg_echo('groups:yours');
$content_menu .= ' (';
$content_menu .= elgg_get_entities_from_relationship_count(array(
'type' => 'group',
'relationship' => 'member',
'relationship_guid' => elgg_get_page_owner_guid(),
'full_view' => false,
'view_toggle_type' => false,
'count' => true
));
$content_menu .= ')';
$content_menu .= '<br>';
$content_menu .= elgg_echo('friends');
$content_menu .= ' (';
$content_menu .= elgg_get_entities_from_relationship(array(
'relationship' => 'friend',
'relationship_guid' => elgg_get_page_owner_guid(),
'types' => 'user',
'count' => true
));
$content_menu .= ')';
$content_menu .= '<br>';
$content_menu .= elgg_echo('friends:of');
$content_menu .= ' (';
$content_menu .= elgg_get_entities_from_relationship(array(
'relationship' => 'friend',
'relationship_guid' =>  elgg_get_page_owner_guid(),
'inverse_relationship' => TRUE,
'types' => 'user',
'count' => true
));
$content_menu .= ')';

Counts of Friends, Friends of and Groups on the User's Profile for Elgg 1.8

Share on Facebook
Share on Twitter




47 Responses to “Display count of Friends and Groups for Profile”

  1. Nudeler2 says:

    Hi,

    to show date of registration in profile would be great!

    One question: what is "Friends of"?…

    • pianist says:

      ……..date of registration in profile…….

      Open the file
      elgg\mod\profile\views\default\profile\owner_block.php
      After this code
      $content_menu = elgg_view_menu('owner_block', array(
      'entity' => elgg_get_page_owner_entity(),
      'class' => 'profile-content-menu',
      ));
      Add this code
      $content_menu .= elgg_echo('usersettings:statistics:label:membersince');
      $content_menu .= ' (';
      $content_menu .= date("r",$user->time_created);
      $content_menu .= ')';

      …….what is "Friends of"……..
      Friends of aka Followers – People who have made you a friend

      ;)

  2. pianist says:

    Another hack:
    How can to display count of Files in Profile

    Open the file
    elgg\mod\profile\views\default\profile\owner_block.php

    After this code
    $content_menu = elgg_view_menu('owner_block', array(
    'entity' => elgg_get_page_owner_entity(),
    'class' => 'profile-content-menu',
    ));

    Add this code
    $content_menu .= elgg_echo('file');
    $content_menu .= ' (';
    $content_menu .= elgg_get_entities(array(
    'types' => 'object',
    'subtypes' => 'file',
    'full_view' => false,
    'view_toggle_type' => false,
    'count' => true
    ));
    $content_menu .= ')';

  3. JPardee says:

    how about displaying the amount of posts on your messageboard?

    • pianist says:

      Open the file
      elgg\mod\profile\views\default\profile\owner_block.php

      After this code
      $content_menu = elgg_view_menu('owner_block', array(
      'entity' => elgg_get_page_owner_entity(),
      'class' => 'profile-content-menu',
      ));

      Add this code
      $content_menu .= elgg_echo('messageboard:board');
      $content_menu .= ' (';
      $content_menu .= elgg_get_annotations(array(
      'annotations_name' => 'messageboard',
      'guid' => elgg_get_page_owner_guid(),
      'count' => true,
      ));
      $content_menu .= ')';

      Have a nice ElggHackDay ;) !

  4. JPardee says:

    ok one more i have amount of gifts sent with:
    $content_menu .= 'Gifts Sent';
    $content_menu .= ' (';
    $content_menu .= elgg_get_entities_from_relationship_count(array(
    'types' => 'object',
    'subtypes' => 'gift',
    'owner_guid' => elgg_get_page_owner_guid(),
    'full_view' => false,
    'view_toggle_type' => false,
    'count' => true
    ));
    $content_menu .= ')';

    but how do i do gifts received???

  5. JPardee says:

    how about gifts you have been given? iv got the code for gifts sent figured out already

    • pianist says:

      Try this hack for Gifts Sent:

      Open the file
      elgg\mod\profile\views\default\profile\owner_block.php

      After this code
      $content_menu = elgg_view_menu('owner_block', array(
      'entity' => elgg_get_page_owner_entity(),
      'class' => 'profile-content-menu',
      ));

      Add this code
      $content_menu .= elgg_echo('gifts:sent');
      $content_menu .= ' (';
      $content_menu .= elgg_get_entities(array(
      'types' => 'object',
      'subtypes' => 'gift',
      'full_view' => false,
      'view_toggle_type' => false,
      'owner_guid' => elgg_get_page_owner_guid(),
      'count' => true
      ));
      $content_menu .= ')';

    • pianist says:

      For Gifts Received need to use the code on another places\pages not into\under owner_block.

      Try this hack for it:

      $user_guid = elgg_get_logged_in_user_guid();
      $ogifts = elgg_get_entities(array('type' => 'object', 'subtype' => 'gift'));
      foreach($ogifts as $gift) {
      if($gift->receiver == $user_guid) {
      $imagefile = "gift_".$vars['entity']->gift_id."_tiny.jpg";
      echo '<img src="'.$vars['url'].'mod/gifts/images/'.$imagefile.'" />';
      }
      }

      You'll receive only the gift's tiny_icons with no descriptions\messages\titles etc…

  6. Nudeler2 says:

    pianist says:
    3 February 2012 at 08:00

    Do U mean the QUOTA?
    OK.
    I'll try to write special post for it.
    Coming soon ;)
    Reply

    Nudeler2 says:
    3 February 2012 at 08:16

    Thanks!

    Yes, for each member. I guess that can be done in the 'file' plugin. I didn't look into it yet, i'm just busy with the htmlawed plugin, for the moment.
    __________________________

    You helped a lot. Thanks al lot therefore. But this is e real needed relevant hack.

    Does there come anything?

  7. Nudeler" says:

    Another one:

    How to display latest acivity (online) for profile? :)

  8. mike says:

    Where can change the profile url of member to /profile/username not profile/id =123456

    • pianist says:

      Hmmm..

      All user profiles are displayed like /profile/username in Elgg by default.
      Perhaps you changed something in the files or install a new plugin.

      You can to try searching for 'profile/id' or 'profile/$user->guid' in the all Elgg files and then replace it with 'profile/$user->username'

      But I can not help you without the more information about the problem :(

  9. priya says:

    Hi pianist,

    I want to display the user name on the topbar when he is logged in.

    Is it possible in elgg 1.8. Is there any solution for this. Please reply me.

    Thanks,

    • alexfalk says:

      elgg_unregister_menu_item('topbar', 'profile');
      elgg_register_menu_item('topbar', array(
      'href' => "/profile/$user->username",
      'name' => 'account',
      'priority' => 1000,
      'section' => 'alt',
      'text' => $user->name,
      ));

  10. curious says:

    Hi thank you so much for helping with this code.

    I am wondering if it is possible to display on the profile page the number of page views (i.e. times that a profile has been viewed by everyone in total?).

    Thanks,

  11. Javier says:

    Hi, thanks for this post, is has been really helpful. I have one question. Im using groups and i want a link to appear in the profile menu to "My Groups" for example.

    How can i do that. Can anyone help me? im using elgg 1.8.

    Thanks a lot.

    • pianist says:

      Open the file
      elgg\mod\groups\start.php
      After this code
      elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'groups_activity_owner_block_menu');
      Add this code
      elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'groups_owner_block_menu');
      Add this code in the end of file
      function groups_owner_block_menu($hook, $type, $return, $params) {
      $url = "groups/member/{$params['entity']->username}";
      $item = new ElggMenuItem('groups', elgg_echo('groups'), $url);
      $return[] = $item;

      return $return;
      }

  12. unRar says:

    Pianist, a mad regard to you for all the help!
    Absolute Respect!

  13. Jothirajan says:

    I followed this code to show the no of files uploaded by a user

    $content_menu .= elgg_echo('file');
    $content_menu .= ' (';
    $content_menu .= elgg_get_entities(array(
    'types' => 'object',
    'subtypes' => 'image',
    'owner_guids' => page_owner_entity()->guid,
    'full_view' => false,
    'view_toggle_type' => false,
    'count' => true
    ));
    $content_menu .= ')';

    BUT IT IS POSSIBLE TO SHOW ONLY THE VIDEO FILE COUNTS, I WANT TO DISPLAY ONLY THE TOTAL NUMBER OF VIDEOS UPLOADED BY THE USER. PLEASE HELP

    • pianist says:

      Your code is displays the images count.
      You need add this code:

      $content_menu .= elgg_echo('videos');
      $content_menu .= ' (';
      $content_menu .= elgg_get_entities(array(
      'types' => 'object',
      'subtypes' => 'videos',
      'owner_guids' => $user->guid,
      'full_view' => false,
      'view_toggle_type' => false,
      'count' => true
      ));
      $content_menu .= ')';

      Note: This is code for Videos Elgg plugin: http://elgghacks.com/plugins#videos

  14. Win says:

    Hi pianist. Can you make the add-ons with buttons the same as the blogs, bookmarks, files, pages, wire posts so that they will look neat too. Thanks and more power. I've learned a lot from your posts here.

Leave a Reply



Similar Elgg Hacks