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) »
  • Show Civi Content in a Drupal Node (Solved with API and contemplate)
Pages: [1]

Author Topic: Show Civi Content in a Drupal Node (Solved with API and contemplate)  (Read 1292 times)

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
Show Civi Content in a Drupal Node (Solved with API and contemplate)
February 23, 2012, 07:39:59 am
I am struggling with this problem - (drupal 6.x / civi 3.4)

What I need is to show civi fields as a views block in a related drupal node.  Each drupal node has a corresponding civi contact.   

I'm so close with setting up a view argument that causes the view to show depending upon the contact reference field in the node (which points to the corresponding civi contact).  I'm hitting my head up against a wall with the default argument php.   

Has anyone accomplished this and could provide me with a snippet to point me in the right direction?

have looked throughout the forum for answers.  Closest I came is this: http://forum.civicrm.org/index.php/topic,19637.msg81693.html#msg81693
But this is using content template and the contact reference field.
« Last Edit: February 27, 2012, 10:05:26 pm by jhofer »

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: Show Civi Content on a Drupal Node (Views Integration)
February 26, 2012, 10:06:15 pm
I went the contemplate route instead of using views.  Here is the code in node-profile.tpl.php (profile is the name of my drupal content type)

<?php
if ( ! civicrm_initialize( ) ) {
       return;
}
require_once 'api/api.php';
$profile_id = $node->field_civicrm_link[0]['contact_id'];
$profile = civicrm_api("Contact","get", array ('version' =>'3', 'contact_id' => $profile_id));
?>
<?php print $profile['values'][$profile_id]['street_address'];?>

This extends the functionality of drupal and civicrm greatly... allowing me to create a drupal node for each civi contact and display both civi and drupal fields on the same page.  Now I need to tackle displaying custom content!
« Last Edit: February 26, 2012, 10:12:26 pm by jhofer »

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: Show Civi Content on a Drupal Node (Solved with API and contemplate)
February 27, 2012, 10:02:27 pm
Added this to above to include custom fields (custom group="bhc" custom fields="Mission__Organization_s_Description", "Cultural_Programs", and "Other_Programs")

<?php

$params = array( 'entity_id' => $profile_id, 'version' => 3,
  'entity_table' => '',
  'return.bhc:Mission__Organization_s_Description' => 1,
  'return.bhc:Cultural_Programs' => 1,
  'return.bhc:Other_Programs' => 1,
  'sequential' => 1,
  );

$fields = civicrm_api('CustomValue','Get',$params);
if( $fields['is_error'] == 0)
{
  $Mission = $fields['values'][0][0];
  $Cult_Prog = $fields['values'][1][0];
  $Oth_Prog = $fields['values'][2][0];
}

?>
<h3>Mission Description</h3>
<p><?php print $Mission; ?></p>
<h3>Cultural Programs</h3>
<p><?php print $Cult_Prog; ?></p>
<h3>Other Programs</h3>
<p><?php print $Oth_Prog; ?></p>


Now... how do I print an array for a multi-select custom field?
« Last Edit: February 27, 2012, 10:03:58 pm by jhofer »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Show Civi Content in a Drupal Node (Solved with API and contemplate)

This forum was archived on 2017-11-26.