Hello,
I have been trying to get this wonderful module to work with realname module, instructions here : ( http://drupal.org/node/329662 ); and without any luck. i will post the instructions required below and if anyone can have any pointers, ill be be more than very grateful.

The code posted below shows the realname module supporting two other modules on drupal, i.e the Content profile and Core module. How can i integrate the address module is the question?

The Real Name module can be extended to support other modules that may supply data to Real Name. This capability was designed to be somewhat flexible.
Specifying a Module

The first task is to tell Real Name that another module is available and whether or not it can supply more than one content type. This is done in the "realname_supported.inc" file.

// $Id: realname_supported.inc,v 1.1.2.2 2008/11/03 20:10:34 nancyw Exp $
/**
* @file
* Realname module support list.
*/

function realname_supported_modules() {
  $list = array(
    'content_profile' => array(
      'name' => 'Content Profile',
      'types' => TRUE,
      ),
    'profile' => array(
      'name' => 'Core Profile',
      'types' => FALSE,
      ),
    );
  return $list;
}

This function returns an array that is keyed by the internal module name and contains a "name" part that is the external module name, and a "types" part that indicates whether the modules supports multiple content types.

That was the easy part. Now, we have to build the support pieces.
Support Functions

All of the support functions are included in a file called "realname_mymodule.inc" where mymodule is the internal module name for which you are building support.

// $Id: realname_content_profile.inc,v 1.1.2.2 2008/11/03 20:11:09 nancyw Exp $
/**
* @file
* Realname module support for Content Profile module.
*/

/**
* Implementation of hook_profile_load();
*/
function content_profile_load_profile(&$account, $type = NULL) {
  $profile = content_profile_load($type, $account->uid);
  if (!$profile) {
    return;
  }
  $fields = content_fields(NULL, $type);
  foreach ($fields as $field_name => $field_attributes) {
    $values = array();
      $contents = $profile->$field_name;
      foreach ($contents as $content) {
        if (isset($content['value'])) {
          $values[] = $content['value'];
        }
        else {
          $values[] = content_format($field_name, $content);
        }
      }
    if (empty($account->{$field_name})) {
      switch (count($values)) {
        case 0:
          $account->{$field_name} = NULL;
          break;
        case 1:
          $account->{$field_name} = $values[0];
          break;
        default:
          $account->{$field_name} = $values;
      }
    }
  }
}

function realname_content_profile_get_types() {
  return content_profile_get_types('names');
}

function realname_content_profile_get_fields($current) {
  $fields = $links = array();
  $all_fields = content_fields(NULL, $type);
  foreach ($all_fields as $field_name => $field_attributes) {
    switch ($field_attributes['type']) {
      case 'text':
        if (!$field_attributes['multiple']) {
          $selected = array_key_exists($field_name, $current);
          $fields[$field_name] = array(
            'title' => $field_attributes['widget']['label'],
            'weight' => $selected ? $current[$field_name] : 0,
            'selected' => $selected,
            );
        }
        break;

      case 'link':
        $links[$field_name] = $field_attributes['widget']['label'];
    }
  }
  return array('fields' => $fields, 'links' => $links);
}

Comments

AlexisWilke’s picture

Are you sure that the name of that function is correct?

/**
* Implementation of hook_profile_load();
*/
function content_profile_load_profile(&$account, $type = NULL) {

It seems that it should be realname_profile_load() instead. This being said, the easiest way I have found is to add a drupal_set_message('Came here', 'error'); to make sure that the functions get called. Because that could very well be the problem.

Once you make it work, maybe we could add that to the addresses module as a sub-module for others using the realname feature.

Thank you.
Alexis Wilke

NancyDru’s picture

Yes, it is correct. This is one of those cases where a module has to provide a function that does not naturally occur in the module itself (much like e.g. Token does).

I suspect that the address field is either not "text" or "link" or is allowed to have multiple values.

brayo4’s picture

Any help..........?? thanks in advance.

AlexisWilke’s picture

brayo4,

You did not answer my question in #1 yet...

Thank you.
Alexis

brayo4’s picture

Hello,
I requested NancyDru to answer that question (as above) since she is the maintainer of the Realname module. I am a non programmer, just off the street type guy so i did not want to make any misleading statements. So i believe she is able to shed more light if more is required. thank you in advance.

NancyDru’s picture

Thought my answers were clear?

AlexisWilke’s picture

brayo4,

I guess it was not a clear answer to my question then. If the load function has to be called content_profile_load_profile(), then there can be only one and thus only one module can support that functionality. Probably not the way it is done. If it is, it will create conflicts.

Thank you.
Alexis

NancyDru’s picture

I don't think Addresses really has to do anything.

      case 'text':
        if (!$field_attributes['multiple']) {

If the CCK field type is "text" and Brayo limits it to a single value, then RealName should automatically see the addresses delivered by the Content Profile module.

brayo4’s picture

Hello, Ive tried everything and i still come up short. Please look at code below and advise......

realname_supported.inc

// $Id: realname_supported.inc,v 1.1.2.2 2008/11/03 20:10:34 nancyw Exp $
/**
 * @file
 * Realname module support list.
 */

function realname_supported_modules()
 {
 $list = array( 'content_profile' => array('name'=> 'Content Profile','types' => TRUE,),
'profile' => array(
 'name' => 'Core Profile',
 'types' => FALSE,),
 'addresses' => array( 'name' => 'addresses', 'types' => FALSE, ),); return $list;
}

 realname_adresses.inc

<?php
// $Id: realname_content_profile.inc,v 1.1.2.2 2008/11/03 20:11:09 nancyw Exp $
/**
* @file
* Realname module support for Content Profile module.
*/

/**
* Implementation of hook_profile_load();
*/
function content_profile_load_profile(&$account, $type = NULL) {
  $profile = addresses_load($type, $account->uid);
  if (!$profile) {
    return;
  }
  $fields = content_fields(NULL, $type);
  foreach ($fields as $field_name => $field_attributes) {
    $values = array();
      $contents = $profile->$field_name;
      foreach ($contents as $content) {
        if (isset($content['value'])) {
          $values[] = $content['value'];
        }
        else {
          $values[] = content_format($field_name, $content);
        }
      }
    if (empty($account->{$field_name})) {
      switch (count($values)) {
        case 0:
          $account->{$field_name} = NULL;
          break;
        case 1:
          $account->{$field_name} = $values[0];
          break;
        default:
          $account->{$field_name} = $values;
      }
    }
  }
}

function realname_addresses_get_types() {
  return addresses_get_types('names');
}

function realname_addresses_get_fields($current) {
  $fields = $links = array();
  $all_fields = content_fields(NULL, $type);
  foreach ($all_fields as $field_name => $field_attributes) {
    switch ($field_attributes['type']) {
      case 'text':
        if (!$field_attributes['multiple']) {
          $selected = array_key_exists($field_name, $current);
          $fields[$field_name] = array(
            'title' => $field_attributes['widget']['label'],
            'weight' => $selected ? $current[$field_name] : 0,
            'selected' => $selected,
            );
        }
        break;

      case 'links':
        $links[$field_name] = $field_attributes['widget']['label'];
    }
  }
  return array('fields' => $fields, 'links' => $links);
}

Please advice......