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
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 .= ')';





Hi,
to show date of registration in profile would be great!
One question: what is "Friends of"?…
……..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
Thanks very much! This is very usefull.
Another question I have: how to restrict the total amount of file upload for each user?
Use .htaccess rule:
# upload_max_filesize is the maximum size of a single uploaded file (5 MB)
php_value upload_max_filesize 52428800
I don't mean single upload, I mean so, to set uploadspace f.e. to total 50 mb files.
Do U mean the QUOTA?
OK.
I'll try to write special post for it.
Coming soon
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.
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 .= ')';
Thanks for this hacks!
how about displaying the amount of posts on your messageboard?
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
!
Thanks.
This is great. I guess you are reading activity-page in elgg.org, too – right?
Sometimes
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???
how about gifts you have been given? iv got the code for gifts sent figured out already
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 .= ')';
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…
so basicly its like the gifts widget, ok iv already got that, i have an idea, can we re mod the gifts plugin to create an annotation so every gift from now on can be counted?
Good idea
how could i do this? im pretty good with php but i need a little direction
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?
I have not forgotten about it.
I need to do a lot of changes in the mod\file.
I need to do it without any errors.
I'll try to finish the job quickly.
Oh, so it's more work than I thought.
OK. Do not feel urged. Just take your time.
Thanks.
u r so kindly
Ahem, sorry, I mean it, I was not aware, that this is so much work. I apologize.
Thanks a lot.
Hi, Nudeler2. Don't worry. All OK
Another one:
How to display latest acivity (online) for profile?
Why not use a widget 'Activity' for Profile?
Or do u mean the user's status (ie, online-offline)?
Hi,
I do not mean the online status, I mean last activity of the user as in user account statistics.
Plz, read it: http://elgghacks.com/display-the-statistics-on-profile/
I have not written about Email and the Full name. It's possible in to Edit profile
"I have not written about Email and the Full name."
What mean?
You asked me about account statistics: Settings -> Account statistics
It includes some details as Full name – Email – Member since – Last logged in ..
Ah. No, name and email are already there on profile, and email has rights to set, so doesn't make sense to set in the userblock.
Thanks.
Where can change the profile url of member to /profile/username not profile/id =123456
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
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,
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,
));
Hi alexfalk,
Thank u very much for ur reply. It works in my website.
Thanks a lot.
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,
Install this Elgg plugin:
Then activate it and Add new widget 'Recent profile visitors' on the Profile page
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.
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;
}
Pianist, a mad regard to you for all the help!
Absolute Respect!
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
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
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.
Sure
Try this plugin http://weborganizm.org/totemz/v/2015/elgg-hacks#up_3457