1

I'm creating blocks to show a Drupal user's relationships on their user page. I've been able to create the views necessary to show the Display Names of the contacts in both the user's A to B relationships and of B to A relationships. I'd like to display the name of the relationship as well for each contact. There is a Views Field for Relationship Type A-to-B, but I can't find a Relationship Type B-to-A field. Any ideas? If one does not exist or cannot be created by tweaking something in the Views UI, how would I go about creating the field in code?

Drupal 7.41, CiviCRM 4.6.6, CiviCRM_Entity module 2.x

2
  • 1
    Agree it looks like it doesn't exist and can't be 'influenced' by applying the relationship to that field. You could see if starting with a View based on Relationships doesn't trip you up somewhere else. I will fire this off at Torrance and see if he can give you a quick 'how to' for patching this.
    – petednz - fuzion
    Dec 2, 2015 at 4:46
  • Thank you Pete, that would be great and much appreciated! Dec 2, 2015 at 7:33

1 Answer 1

3

It is correct that not all fields from the CiviCRM RelationshipType entity are available in the the views by default. The socialistic party in the Netherlands had the same problem. And I created a drupal module for them to fix this.

You can find the module at https://github.com/SPnl/nl.sp.drupal-civicrm-views-enhancement

This module adds the name-a-b, label-a-b, name-b-a, label-b-a, contact-type-a, contact-type-b, contact-sub-type-a, contact-sub-type-b, description, is-reserved, is-active to drupal views.

6
  • Sounds great Jaap - what chance of this getting provided back to core as a patch?
    – petednz - fuzion
    Dec 2, 2015 at 19:02
  • I don't have a plan to do that. However feel free to reuse the code for a core patch. Dec 2, 2015 at 19:04
  • @petednz-fuzion, this fixed it for me, but I'd be interested in taking my coding skills up a notch and learning how to patch this in so others can benefit. Where would this code need to go for a patch? Into Civi Core (where?), the CiviCRM_Entity module, or some other place? I'm willing to do the work, just need a little direction. :) Dec 2, 2015 at 19:26
  • 1
    The first thing you have to do is to report this as an issue in the issue tracker at issues.civicrm.org Then you have to set up a local development environment. I have written a blog on how to do that: jaapjansma.nl/2015/08/25/… after you have done so you could start fixing the bug. This bug should probably be fixed in the civicrm-drupal project on github: github.com/civicrm/civicrm-drupal Dec 2, 2015 at 21:11
  • Thank you @JaapJansma! This will be a great project for me. Dec 4, 2015 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.