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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Drupal CiviCRM Contact Reference and Rules token support?
Pages: [1]

Author Topic: Drupal CiviCRM Contact Reference and Rules token support?  (Read 1322 times)

chiebert

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 1
  • CiviCRM version: 4.3
  • CMS version: Drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
Drupal CiviCRM Contact Reference and Rules token support?
December 18, 2012, 10:42:46 am
Hey there - I notice that (as of 4.2.6) the Drupal civicrm_contact_reference field module isn't completely functional with Drupal Rules (7.x-2.x). Here's my situation:

  • I have a Drupal content type (Land Asset) that uses a CiviCRM (4.2.6) Contact Reference field to point to Organisations in the Civi DB.
  • I've got a ctools page manager page (with panels) that displays various views panes full of info related to the org - the custom path is something like /asset-management/%cid/summary - where %cid is the Civi contact_id of the organisation. This, of course, becomes a context that can be passed to the included views content panes.
  • Finally, I have the view of the Drupal 'Land Asset' node (which, you remember, contains a CiviCRM Contact Ref field).

Now, (among other things) I'd like to make sure that when a user is viewing a Land Asset node, the breadcrumb is set to /asset-management/%cid/summary - where %cid is the raw contact_id from the contact ref field. My first quick-and-dirty way to do this was to use a Rules reaction triggered by 'view content' where 'content type is Land Asset' and the reaction is to 'set breadcrumb' appropriately. Normally, one would do this using token (or token-like) replacement patterns, and there is indeed a token for the contact ref field: in my case, [node:field_asset_parish].

But the output of this token is only (and always) a html-formatted link, for example: <a href="/civicrm/contact/view?reset=1&cid=448">Christ Church, Alert Bay</a>. There are no 'chaining' options that I've been able to make work in order to get at the actual raw cid from the reference field. Following from other reference fields (like Entity Reference, for example), one would expect to be able to use something like: [node:field_asset_parish:contact_id] or [node:field_asset_parish:title] to get at the cid or the display name, respectively.

Note that Views is already allowing something like this for the existing civicrm_contact_ref field, at least in the field rewriting section, i.e., [field_asset_parish-contact_id] is available as a working replacement pattern - although you can't currently choose 'raw contact id' as a formatter option, either in Views or in Manage Display for a content type (I've modified my civicrm_contact_ref.module to allow for this, and will submit a patch for consideration as soon as I post this).

So that's the situation. I've spent a couple of days trying to see how (for example) Entity Reference implements Rules 'chaining' in the hopes of adding this kind of functionality to civicrm_contact_ref, but I'm drawing a blank. Throwing it out there to see if anyone's already done this, or knows how to proceed. Meanwhile, I'll revert to using Drupal hooks in a custom module to re-set the breadcrumb. But ultimately this would be good basic integration to get into Civi, n'est pas?

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: Drupal CiviCRM Contact Reference and Rules token support?
January 16, 2013, 09:28:37 pm
See related posts: http://forum.civicrm.org/index.php/topic,27227.0.html
http://forum.civicrm.org/index.php/topic,24292.0.html

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Drupal CiviCRM Contact Reference and Rules token support?

This forum was archived on 2017-11-26.