CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • View of Civi Custom field linked to Drupal node
Pages: [1]

Author Topic: View of Civi Custom field linked to Drupal node  (Read 2013 times)

dowd

  • I’m new here
  • *
  • Posts: 21
  • Karma: 0
View of Civi Custom field linked to Drupal node
March 22, 2012, 09:09:33 am
Hi, I have a Drupal content type (called team) that references multiple Civi contacts (using CiviCRM CCK Contact reference module). I am using views to display a list of the teams with the names of the Civi Contacts. I would like to be able to pull more information from Civi than just the contact name (including custom fields) but I can't seem to work out how!
I have tried using relationships and arguments.
I have tried using Views Field View module but can't seem to get the argument bit to work.
It seems to be that if you do a view based on a CiviCRM Contact you can't pull in any information from the rest of Drupal; but if I do a view based on Drupal nodes I can seem to only get the Contact name even with a relationship put in.

Any help gratefully received!

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: View of Civi Custom field linked to Drupal node
March 22, 2012, 11:08:07 am
Quote from: dowd on March 22, 2012, 09:09:33 am
It seems to be that if you do a view based on a CiviCRM Contact you can't pull in any information from the rest of Drupal; but if I do a view based on Drupal nodes I can seem to only get the Contact name even with a relationship put in.

I believe that is correct.

The way to get additional data from your Contact would be by customizing one of your View templates and then using the CiviCRM API, but you would need PHP skills for that.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: View of Civi Custom field linked to Drupal node
March 22, 2012, 12:29:40 pm
hi - if this is helpful i will need to find where we wrote this up but we have something like the following
- Drupal Node = Party
- Node has a Civi Reference field to the Civi Contact for the Party
- Party is related in civicrm to various individuals eg CoLeader
- we pull a block on to the Party page that shows the CoLeader name/phone etc

Does that sound like what you are aiming for?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

dowd

  • I’m new here
  • *
  • Posts: 21
  • Karma: 0
Re: View of Civi Custom field linked to Drupal node
March 23, 2012, 10:02:00 am
Hi, thanks for your replies.
petednz - I think what I am wanting is not quite the same as that example (I want a whole list of people and details) but is probably close enough that if you could share how you did that it would be very useful as I am not the best at PHP (I prefer changing code rather than startign from a blank page/screen!)

jhofer

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 3.x
  • CMS version: Drupal 6.x
  • MySQL version: 5.x
  • PHP version: 5.x
Re: View of Civi Custom field linked to Drupal node
April 15, 2012, 10:25:30 am
I had a similar question - and like you I'm better at tweaking code than starting from scratch.  It took me a while to figure things out ... here is a log of my discovery (and the php code): http://forum.civicrm.org/index.php/topic,23560.msg99250.html#msg99250    my code has evolved greatly since posting that but the basics of how to call the API and link the node to the CiviCRM record through  $profile_id = $node->field_civicrm_link[0]['contact_id'];   is there

The key lies in using contemplate for the body of your content type "Team".  PHP code goes into contemplate to be able to call the CiviCRM API.  Study up on the API it will help you greatly: http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+Public+APIs  The explorer greatly helped me to understand how the API works since you can play around with your data: # api explorer (visit /civicrm/ajax/doc/api#explorer on your installation) - see  our screencasthttp://www.youtube.com/watch?hl=en&v=G_mLgR-rbGg&gl=US

Hope this is helpful... in the middle of watching kids and making pancakes!

jhofer

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 3.x
  • CMS version: Drupal 6.x
  • MySQL version: 5.x
  • PHP version: 5.x
Re: View of Civi Custom field linked to Drupal node
April 15, 2012, 10:28:15 am
Oh and just to clarify... I never figured out how to use Views to link a node to a civicrm contact.  It's gotta be through arguments php code.  This solution is using just contemplate module.

dowd

  • I’m new here
  • *
  • Posts: 21
  • Karma: 0
Re: View of Civi Custom field linked to Drupal node
April 18, 2012, 08:23:40 am
Thanks jhofer for your input.
In the end I have worked out how to do it via views and inserting a view (inside my view of my team) of the civicontacts using an argument of the CiviCRM ID and linking that to the Members field.
When you have more than one member I had to use the views customfield module http://drupal.org/project/views_customfield and insert php code (brilliant module especially together with the Civi API) to break up the array.
If anyone wants a more detailed explanation just let me know (I probably haven't explained it very well here)

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: View of Civi Custom field linked to Drupal node
April 18, 2012, 10:05:32 am
Right, using http://drupal.org/project/views_customfield is an alternative to customizing the view templates.

Glad to hear you got it working.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • View of Civi Custom field linked to Drupal node

This forum was archived on 2017-11-26.