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) »
  • Relate a CiviCRM case to 1+ Drupal nodes of a content type?
Pages: [1]

Author Topic: Relate a CiviCRM case to 1+ Drupal nodes of a content type?  (Read 1029 times)

ponch

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 4.2.4
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3.9
Relate a CiviCRM case to 1+ Drupal nodes of a content type?
November 05, 2012, 12:34:15 pm
I have been searching for help on how to do this for a while, and I see how (I think) to add CiviCRM content to Drupal. But, what I want to do is the opposite.

I have a Drupal content type called "books". I would like to be able to relate a CiviCRM case to 1 or more books (nodes of that content type).

At first, I though I could do this with custom fields, but I can't figure anything out.

Is this even possible? Any ideas?

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Relate a CiviCRM case to 1+ Drupal nodes of a content type?
November 05, 2012, 01:16:17 pm
What is the task being performed that would use this relation? For example, if the task is: "Case manager is at manage case screen and wants to navigate to the appropriate book nodes (documentation?)", then you could do it with a custom field textarea, and copy and paste the urls of the book node(s) into that field. Low-tech but depends how much more you need.

ponch

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 4.2.4
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3.9
Re: Relate a CiviCRM case to 1+ Drupal nodes of a content type?
November 05, 2012, 01:38:52 pm
Yes, you've basically got it.

But I'd like to preserve the relationship so that, if desired, the case manager could look at the book node/entity and also see which cases the book was used a documentation.

I thought about making a new entity in CiviCRM, but that seems like quite an undertaking, never mind the "relatedness" that needs to happen.

Books are currently a Drupal content type because these nodes also need to be viewable from the CMS side.

Does that help?

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Relate a CiviCRM case to 1+ Drupal nodes of a content type?
November 05, 2012, 01:55:44 pm
I can't think of an off-the-shelf way to do it but you could write a little module that implements hook_nodeapi (drupal hook not a civi hook) for the view action and looks up all cases that reference the current node, then add that to the node for display.

To make it more robust/user-friendly, on the civi side make the custom field a multi-select widget and implement hook_customFieldOptions in your module to have the select options be all the book nodes (node id for the key, node title or whatever for the display value).

Alternatively, have your module present a custom field on the drupal book nodes to select from all cases, then on the civi side implement hook_caseSummary to display links to the nodes.

ponch

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 4.2.4
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3.9
Re: Relate a CiviCRM case to 1+ Drupal nodes of a content type?
November 05, 2012, 02:03:01 pm
Thanks very much for your help so far. I don't mind doing it all custom if I have to, but of course I'd prefer configuration over code.

If you have a minute for a question, do you think it would be easier to create a new CiviCRM entity called "Book" and then figure out 1) how to relate that to cases (also contacts actually), and 2) how to display this entity in the Drupal side?

#1 seems possible, but #2 seems pretty tricky (to me, anyway).

Would that streamline things any, do you think?


Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Relate a CiviCRM case to 1+ Drupal nodes of a content type?
November 06, 2012, 03:30:07 am
I think the first solution suggested is best--just directly relate nodes to Cases. You would need to custom code this in Drupal using hooks to fetch/display the information on both ends, as demeritcowboy wrote.
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.

ponch

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 4.2.4
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3.9
Re: Relate a CiviCRM case to 1+ Drupal nodes of a content type?
November 06, 2012, 07:21:05 am
Yes, I see how that makes sense. But could it be implemented? Looks like the CiviCRM Reference module doesn't apply to cases?

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Relate a CiviCRM case to 1+ Drupal nodes of a content type?
November 06, 2012, 08:08:53 am
That's probably correct. There isn't an API for cases either, last I checked.

Therefore you would have to write the SQL to access the data you need.
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.

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Relate a CiviCRM case to 1+ Drupal nodes of a content type?
November 06, 2012, 03:55:41 pm
There is an API for cases, but I don't know off the top of my head if it does what you want. (See api/v3/Case.php)

If by reference module you mean drupal/civicrm.module.sample, it should have all the hooks in it, but may not have that many examples specific to CiviCase.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Relate a CiviCRM case to 1+ Drupal nodes of a content type?

This forum was archived on 2017-11-26.