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
Comment #1
AlexisWilke CreditAttribution: AlexisWilke commentedAre you sure that the name of that function is correct?
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
Comment #2
NancyDruYes, 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.
Comment #3
brayo4 CreditAttribution: brayo4 commentedAny help..........?? thanks in advance.
Comment #4
AlexisWilke CreditAttribution: AlexisWilke commentedbrayo4,
You did not answer my question in #1 yet...
Thank you.
Alexis
Comment #5
brayo4 CreditAttribution: brayo4 commentedHello,
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.
Comment #6
NancyDruThought my answers were clear?
Comment #7
AlexisWilke CreditAttribution: AlexisWilke commentedbrayo4,
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
Comment #8
NancyDruI don't think Addresses really has to do anything.
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.
Comment #9
brayo4 CreditAttribution: brayo4 commentedHello, Ive tried everything and i still come up short. Please look at code below and advise......
realname_supported.inc
Please advice......