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) »
  • Trying to access API from Drupal CCK Computed Field... How?
Pages: [1]

Author Topic: Trying to access API from Drupal CCK Computed Field... How?  (Read 2401 times)

rob123

  • Guest
Trying to access API from Drupal CCK Computed Field... How?
January 17, 2008, 11:48:11 am
I'm trying to access Civi's API from inside a CCK Computed Field but I'm getting undefined function errors when calling any Civi function.

I suspect this may be because the Drupal/CCK Computed Field is being parsed before the CiviCRM Module has registered it's functions, then I could be wrong?

Hope someone out there can shed some light on this or provide a solution.

Thanks

Rob

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Trying to access API from Drupal CCK Computed Field... How?
January 17, 2008, 05:16:08 pm

make sure u initialize civicrm so that some of the core files are loaded. Call the function

civicrm_initialize( true );

to do so

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

rob123

  • Guest
Re: Trying to access API from Drupal CCK Computed Field... How?
January 18, 2008, 01:29:50 am
Donald,

Thanks for the reply,

Unfortunately I have been initializing and still get errors, see below

Code: [Select]
if (module_exists('civicrm')) {
  civicrm_initialize(TRUE);
  $location_types = crm_get_property_values('location_type');
}

Results in:
Quote
Fatal error: Call to undefined function crm_get_property_values()

I am pretty sure this is due to needing lower level access.

Rob

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Trying to access API from Drupal CCK Computed Field... How?
January 19, 2008, 06:12:15 pm

can u specifically add a
require_once 'api/Contact.php';

above the crm_get_property_values clause

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

rob123

  • Guest
Re: Trying to access API from Drupal CCK Computed Field... How?
January 20, 2008, 08:30:00 am
lobo.... you are an absolute star!! That did the trick!

Thank you so much!

Hope the work on version 2 is going well,

I appreciate the support at, what must be, a hectic time with the upcoming beta release.

Rob

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Trying to access API from Drupal CCK Computed Field... How?

This forum was archived on 2017-11-26.