How to add user picture to my relationships block

lsabug - February 16, 2008 - 18:13
Project:User Relationships
Version:5.x-1.0
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

The my relationships block works and displays the name of the user. I would like it to also include the user's picture/avatar but I"m not where I need to put the print user picture code. Has anyone added pictures to their user relationships block?

#1

sprsquish - February 17, 2008 - 21:22

You'll want to override a couple of theme functions:

<?php
 
function theme_user_relationship_block_content($viewing_user, $rtid, $relationships) {}
  function
theme_user_relationship_block_pending($account, $block_type, $rtype, $extra) {}
?>

You can see the current implementation in the user_relationship_block.module file under the plugins directory.

I'd love to see how you implement it; send along the new functions when you finish.

#2

sprsquish - February 22, 2008 - 16:24
Status:active» closed

#3

mariusooms - March 19, 2008 - 15:07
Version:5.x-2.x-dev» 6.x-1.0-beta6

Hi...I'm a beginner as far as coding and am still trying to grasp how to call those functions. I'm transitioning to Drupal 6 and was hoping you could give an example code of what to put in a custom block to show just the UR profile pictures.

Kind regards,

Marius

#4

Prasad Shir - May 19, 2008 - 18:38
Version:6.x-1.0-beta6» 5.x-1.0
Status:closed» active

Hi sprsquish

I am looking for a similar solution. I wish to add user pictures to the User Relationship Block as well as to the User Relationship list.

I understand that I need to override a couple of theme functions. I had a look at user_relationship_theme.inc & gathered that I need to override user_relationships_page function for overriding the default relationships page / list. Is that correct?

I added the following code in my themes template.tpl.php

function phptemplate_user_relationships_page($uid = NULL, $rtid = NULL) {

return _phptemplate_callback('user_relationships_page', array('uid' => $uid, 'rtid' => $rtid));

then i created user_relationships_page.tpl.php file. But now I am struggling! I am only able to print $uid variable using this file.

Can you please let me know

1. which variables are available for the user_relationships_page.tpl.php file to use &

2. how to call / use them?

3. & mainly how to get user pictures in the list / table?

Thanks a lot in advance

(I dont know if I should write here in a closed issue or create a new support request - let me know if I need to move this post to a new issue)

#5

ChristieLuv - May 24, 2008 - 20:59

Yes I think this would be great if someone could figure out how to do this and show everyone! I'm sure many people would like this! It would be a very attractive myspace style friends list. I wish I could but I'm a novice with PHP coding. If someone figures it out, if they could post a step by step instructions for us novices I'm sure many people would appreciate it! Thank you so much!

#6

steve22 - May 30, 2008 - 09:53

subscribing!

#7

d0t101101 - June 4, 2008 - 05:28

I'd also like to see this implemented, subscribing.

#8

Jboo - June 9, 2008 - 22:44

I've just done this by altering the user_relationship_block.module file (although you may prefer to override the function in your template file) so that the theme_user_relationship_block_content function is changed (the theme_user_relationship_block_pending function can be changed as well of course) from username to user_picture like this (just one changed):

<?php
$username
= theme('user_picture', $relatee);
?>
?>

Then I've altered my css like so:

#profile-relationships .content {
text-transform: capitalize;
font-weight:bold;
}

#profile-relationships ul {
list-style:none;
padding:0;
margin:0;
}

#profile-relationships ul li {
list-style:none;
padding:0;
margin:0;
}

#profile-relationships .item-list .picture img {
width:60px;
float:left;
}

The pictures don't align correctly in I.E, but I've only just done this and it shouldn't be too difficult to fix.

#9

Prasad Shir - June 19, 2008 - 13:37

jboo

Thanks for the code suggestion. Tried it & it's working! (though modifying code like this is not ideal, the main thing is its achieving desired result)

Prasad

#10

Jboo - June 20, 2008 - 15:08

No problem. Add display:inline; to the #profile-relationships ul li CSS if you want the images to display correctly in a row (without the staircase effect) in I.E.

#11

nf1 - July 13, 2008 - 19:42

Anyone manage to find how to make the css working? I really can't figure how to remove the staircase effect.

#12

nf1 - July 13, 2008 - 19:54

I'm using panels so the CSS isn't loaded by default. If anyone have the same, in the CSS ID field enter: profile-relationships and all will be fine.

#13

Jboo - July 14, 2008 - 10:29

nf1, does adding display:inline; to the #profile-relationships ul li not work?

#14

wallbay1 - July 19, 2008 - 00:24

very nice but could you tell me where exactly do i have to put the code. please explain like for example:
search code, then add in bottom, top etc.. the code

#15

Jboo - July 19, 2008 - 01:41

In your user_relationship_block.module file that you need to upload with this module, search for theme_user_relationship_block_content (and theme_user_relationship_block_pending if you want to change that also).

Where it says:

<?php
$username
= theme('username', $relatee);
?>

Change to...

<?php
$username
= theme('user_picture', $relatee);
?>

Save the file and upload. Change CSS settings like I mentioned if you like.

#16

eerpini - July 27, 2008 - 22:01

hi everyone ,
i achieved this by simple tweaking in the user_relationships.theme.inc file , instead of diplaying the tabular output i have displayed the user picture and any details available ( the function can be modified to include the user details from the profile module or others) , i used the code used to display the user pictures on the user_profile pages , u can see the changed display of "My relationships" on MentorCorner .

The code i modified looks like :

  $output .= "<hr>".theme_user_picture($this_user);
          $output .= "<br><strong>Username:</strong>".theme('username', $this_user)."<br>".$this_user->name." is your ".$relation->name."<br>";

Also i have written a detailed version of the tweak here :
http://satish.playdrupal.com/?q=node/31

Thanks
Satish

#17

wallbay1 - July 28, 2008 - 05:44

thanks guys i will try that

 
 

Drupal is a registered trademark of Dries Buytaert.