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?

Comments

sprsquish’s picture

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

  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.

sprsquish’s picture

Status: Active » Closed (fixed)
mariusooms’s picture

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

Prasad Shir’s picture

Version: 6.x-1.0-beta6 » 5.x-1.0
Status: Closed (fixed) » 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)

ChristieLuv’s picture

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!

steve22’s picture

subscribing!

d0t101101’s picture

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

Jboo’s picture

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):

$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.

Prasad Shir’s picture

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

Jboo’s picture

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.

Anonymous’s picture

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

Anonymous’s picture

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.

Jboo’s picture

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

wallbay1’s picture

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

Jboo’s picture

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:

$username = theme('username', $relatee);

Change to...

$username = theme('user_picture', $relatee);

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

eerpini’s picture

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

wallbay1’s picture

thanks guys i will try that

liliplanet’s picture

Interesting .. what would worked for me was in the user_relationships.theme.inc

added

theme('user_picture', $this_user),

$rows[] = array(

theme('user_picture', $this_user),
theme('username', $this_user),
$this_user->access > $online_interval ? t('online') : t('not online'),
$edit_access ? theme('user_relationships_remove_link', $viewed_user->uid, $relation) : '&nbsp;',);
    
}
alex.k’s picture

Status: Active » Fixed

Committed to 5.x-2.x branch, with a config option in /user/relationships/settings. Thanks.

steve22’s picture

Version: 5.x-1.0 » 5.x-2.x-dev
Category: support » feature
Status: Fixed » Active

Thanks for committing this most essential feature ! But, pictures are only showing up in relationship pages, but not in user-relationship blocks. And will it be a good idea to also add 'more' option in the block, so that users can go to page from block easily?

alex.k’s picture

@steve22 would you be willing to patch function theme_user_relationship_block_content() in user_relationship_blocks.module to achieve this by adding theme('user_picture') to the output, when the config option is set?

steve22’s picture

StatusFileSize
new799 bytes

alex.k,
I have never written a patch, but this is my first try. It gives the user pictures in block. I think may be we need to create a css file to for 'inline' display of the image.

alex.k’s picture

Status: Active » Needs review

The patch looks ok, thank you. Yes css is a good idea, and should be pretty simple to add by making a css file and then calling http://api.drupal.org/api/function/drupal_add_css/5

I will commit once someone else reviews and applies the patch.

yang_yi_cn’s picture

is it possible to put that to 6.x branch as well?

rc2020’s picture

subscribing

alex.k’s picture

For 6.x it is very easy to create such a block using Views - with a picture and any other fields you need. So there isn't much use patching the block.

lance.gliser’s picture

subscribing

liam mcdermott’s picture

StatusFileSize
new1.76 KB

I had trouble getting the patch in #22 to apply. Also, it wasn't patched from the module directory and had indents of four spaces. What it achieved is sound though, so thank you steve22 for going to the trouble. :)

Here's an updated patch that shows both the user's picture and their name beneath it. It does this using a nested list. Also added a class to the containing ul so it can be targetted easily using CSS (probably not an issue for people who're just using blocks, but vital for us Panels users!)

It applies from the modules/user_relationships directory.

liam mcdermott’s picture

StatusFileSize
new1.97 KB

Oh pants, previous patch had a bug in it. Appears 'data' is required in the array, otherwise theme_item_list will output duplicate relationships.

Uploading another attempt.

RikiB’s picture

Status: Needs review » Reviewed & tested by the community

works great :)

alex.k’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new85.08 KB

@Liam McDermott thanks. Could you make up a stylesheet that tidies up the nested lists? As is I imagine it looks pretty unwieldy on most themes. See attached stock Garland screenshot.

liam mcdermott’s picture

Status: Needs work » Needs review
StatusFileSize
new2.94 KB

I was going to leave that to another issue, but it does look ugly without styling. :)

Here's an updated patch, including a CSS file. The only change to the PHP is the addition of a call to drupal_add_css().

michaeldrupal’s picture

Is there any way to add avatars to friends list by using Views? Please help.

alex.k’s picture

Status: Needs review » Fixed

@Liam McDermott committed http://drupal.org/cvs?commit=216652, thanks much!

@michaeldrupal this is not a Views issue... I'm not sure 5.x Views allow you to do that. I think you would need to override rendering of the view with a custom template, but I haven't used 5.x Views very much...

ajayg’s picture

Version: 5.x-2.x-dev » 6.x-1.x-dev
Status: Fixed » Active

I looked and did not see a corresponding check in to 6.x branch. Making this active and chaging the version to 6.x since it would be really nice to port this to 6.x.

alex.k’s picture

Version: 6.x-1.x-dev » 5.x-2.x-dev
Status: Active » Fixed

Per #26 Views allow you to do that, so there is no need to patch the block. If someone wished to submit a patch, it will be welcome - and please open a new issue rather than changing version tags - but really there is no need. Setting back to 5.x, just trying to keep the issue queue clean.

ajayg’s picture

Oh I am Sorry Alex. I should have read the whole thread. Honestly I thought I am helping you keeping the issue queue current and little I realized I am increasing your work. My bad and sorry again.

alex.k’s picture

No problem, I appreciate you looking into it. Your attention is helpful.

lunarbear’s picture

This is great stuff but could some one tell me how to hide the username and instead use it as the user image alt tag a la Twitter's "Following" display?

Thanky

vijayitsoft’s picture

Title: How to add user picture to my relationships block » No links for add or delete relationship on custom profile page

Hi,

I have installed the user relationship module but the links for add and delete the relationship is not showing

Plz suggest step by step solution for it

thanks

ajayg’s picture

Title: No links for add or delete relationship on custom profile page » How to add user picture to my relationships block

Please don't change the title of issue. So putting it back.

@vijayitsoft your issue looks like a different issue. Please look through existing support issues and if not a known issue then open a seperate issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

drupalmind’s picture

Version: 5.x-2.x-dev » 6.x-1.0-beta10
Status: Closed (fixed) » Needs review

How to add user picture to my relationships block .... i am using the beta10 release of UR module .... i think a lot of code changes .... i am unabe to patches provided as above ... plz help it down

alex.k’s picture

Version: 6.x-1.0-beta10 » 5.x-2.x-dev
Status: Needs review » Closed (fixed)

6.x and 5.x have different code, please open a new support request for 6.x. As mentioned in comment 26 it's quite easy to do using Views, using the "user_relationships_browser" view as a start you can customize it as needed.

venusrising’s picture

I am using panels 3 and the user_relationship blocks lists but I cannot figure out how to make the picture too. I have pictures ticked under admin but I still cannot seem to figure it out.