Hi,

I would like to add 'this user has x amount of relationships' to the content profile template.

Something similar exists for flags as follows:

<?$flag = flag_get_flag('recommend') or die('No "recommend" flag!');

$count = $flag->get_count($uid);

if ($count == 0) {
  print t("");
} else {
  print t('This Member has <a href="@view-url">@in-words</a>', array(
    '@view-url' => url("user/$uid/recommendations"),
    '@in-words' => format_plural($count, '1 Recommendation', '@count Recommendations'),
  ));
}?>

Please, how would I change that for relationships?

Look forward to any reply, and thank you.

Comments

63reasons-AS’s picture

Assigned: Unassigned » 63reasons-AS
63reasons-AS’s picture

Assigned: 63reasons-AS » Unassigned
Liliplanet’s picture

It's been a while .. please would be wonderful if I could either add in a block on or the custom profile tpl

user has X amount of relationships, and perhaps by relationship type?

x number of fans
x number of colleagues

Most appreciate any reply, and thank you :)

Liliplanet’s picture

* bump * sorry .. but this is important, any help most appreciated :)

alexx90’s picture

in drupal forums you will never get answer just forget about that
i asked many times for help before you but no one alive her

mrf’s picture

User relationships doesn't have a function to return a relationships count, but I needed this for UR Limits.

If you install the module you can then use:

user_relationship_limits_relationship_count($rtid, $uid);

Substitute the ID of your relationship for $rtid and $uid is the user's id.

Or just take that function and adapt it for your own needs.

RKS’s picture

I wonder what you would include as $uid if you wanted it global? So if "Friend" is 1 you could substitute that easily but for all users and not just one how would you substitute?

mrf’s picture

Title: User has x user relationship on profile tpl » Provide API function to return relationship counts
Version: 6.x-1.x-dev » 7.x-1.x-dev

Returning pending and total counts for a particular user is a common request and could be useful within the modules own UI.

Blue’s picture

This should better be done with views. Subscribe