Closed (fixed)
Project:
User Relationships
Version:
6.x-1.0-beta9
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
1 Nov 2007 at 10:40 UTC
Updated:
24 Jul 2009 at 21:56 UTC
how to make a link that creates a relationship to be added on the nodeprofile
Comments
Comment #1
sprsquish commentedUser Relationships: Actions block will do what you need
Comment #2
andrenoronha commentedand if I want a custom link?
the only thing I need is to figure out what is this number in the path:
/user/[logged in user]/relationships/[misterious number]/remove?destination=user%2F[viewing user]
This misterious number is driving me wild.....I cant find a pattern...
any help?
Comment #3
IckZ commentedi think this is the userid of the user you want to add. are you using nodeprofile with a template file or what? If you do, you should try to print out get_defined_vars(); there you could find every link.
Comment #4
Plazmus commented[Edit]
I checked and that [misterious number] is the id of relationship, see user_relationships table this is rid field.
Comment #5
IckZ commentedI found that number you can get it with :
global $user;
$current_relationships = user_relationships_load(array('between' => array($user->uid, arg(1))), array('sort' => 'rtid'));
$friend_rid = $current_relationships['1']['0']->rid;
Comment #6
andrenoronha commentedi'm using content profile with no template files.
look these links:
to add user 29 as a friend:
/relationship/29/request/1?destination=user%2F29
everything is right.
now to remove a friend:
remove user 35 from my friend list
/user/32/relationships/32/remove?destination=user%2F35
now remove user 3
/user/35/relationships/23/remove?destination=user%2F3
now remove user 29
/user/35/relationships/27/remove?destination=user%2F29
now remove user 5 from user 3's list
/user/3/relationships/4/remove?destination=user%2F5
crazy numbers....
Comment #7
andrenoronha commented@ IckZ
it worked! thanks!
but what kind of id is it anyway?
ah, i aprreciate your work...but i think i cant use it... because I'm trying to remove the original link of user relationship block, but this link brings other things like a "waiting approve cancel link"...
i just wanted to get the original link out of the html ul list tag...
Comment #8
frankcarey commentedI needed a more universal theme function so I could add in links where i needed them. This takes the arguments of viewer (optional, assumes global $user), and friend_uid, which is the user id you want to create the links for. I also created a template file to theme the actual "link set". It uses the user_relationships_ui module theme functions to create the links, which you can also use. the tirck is knowing which to use, and that's what this theme function does. Hope it's helpfule to someone else. I 'd like to see somethign like this in the module itself. I basically adapted this from it's existing functions, but they weren't generic enough, and were private functions :(
The template file: relationship_links.tpl.php
Comment #9
andrenoronha commentedis this a hook? is it about my question above?
I couldnt implement it...
Comment #10
kvvnn commentedRemoving a Friend from any page that has the friend's ID passed as an argument
Thanks to IckZ for the php code.
Comment #11
Bilmar commentedTo confirm - is the above php code something we should be able to put into Views Custom Field? I have tried but currently not able to get the 'Remove this user as a friend' link to work properly in Views.
Thank you.
Comment #12
kvvnn commentedYes it should work with views. I haven't used a "remove friend" in views but I have used the $relationship object and that is all you should need.
Comment #13
Bilmar commentedI can't seem to get the php code working in the Views Custom Field. I tried adding arguments in the Views which results in No Query Run. Could someone please help test creating a field in Views with the PHP code?
Are arguments and relationships required? And how should they be set up?
It would be very very helpful if someone could provide a views export which I could load to learn/study from.
Thank you very much in advance.
Comment #14
kvvnn commentedHere is the view I use which calls some User Relationships functions in a custom php field (from the module, see above).
It is a list of all users on the site. The custom PHP field determines whether each user is a Friend, Not a friend, or in the pending process.
Comment #15
Bilmar commentedHi Kevin-
I added the attached code to a custom php field in views but the field came up blank for users that I have friends and non-friends relationships. Could I possibly have more direction on how to implement this feature?
Thank you very much in advance!
Comment #16
kvvnn commentedtrupal,
In my example, the Custom PHP field has values like this :
To display some type of user data, you need to replace the "node_data_field_avatar_field_firstname_value" part of that with whatever field you want to display.
You find out what that field is named on YOUR view by first making a Custom PHP field with the following :
This shows you all of your field names. Remember in the PHP field you want to show a user's field in to include the $data=> before this value.