私がやりたいことは Drupal 7 を使用することであり、Location モジュールはノードの場所をユーザーの場所に継承またはデフォルト設定することです。その理由は、ユーザーが 1 つの場所 (プロファイル上) を編集し、そのユーザーによって作成されたすべてのノードに表示されるようにするためです。誰でも助けることができますか?
http://drupal.org/node/1357614
編集:
私はこのモジュールを見つけ、緯度と経度を機能させようとしています (残りの部分と同じように) が、親ケース 'locpick' が私を混乱させており、これを実行できません。
<?php
function location_alter($argument){
$location_alter = array();
global $user;
$uid = $user->uid;
$location_alter = user_load($uid);
$location_alter = $location_alter->location;
return $location_alter[$argument];
}
/**
* Implementation of hook_locationapi().
*/
function locnodeauthor_locationapi(&$obj, $op, $a3 = NULL, $a4 = NULL, $a5 = NULL) {
switch ($op) {
case 'field_expand':
switch ($a3) {
case 'name':
return array(
'#type' => 'textfield',
'#title' => t('Location name'),
'#default_value' => $obj != '' ? $obj : location_alter('name'),
'#size' => 64,
'#maxlength' => 64,
'#description' => t('e.g. a place of business, venue, meeting point'),
'#attributes' => NULL,
'#required' => ($a4 == 2),
);
case 'street':
return array(
'#type' => 'textfield',
'#title' => t('Street'),
'#default_value' => $obj != '' ? $obj : location_alter('street'),
'#size' => 64,
'#maxlength' => 64,
'#required' => ($a4 == 2),
);
// Additional is linked to street.
case 'additional':
return array(
'#type' => 'textfield',
'#title' => t('Additional'),
'#default_value' => $obj != '' ? $obj : location_alter('additional'),
'#size' => 64,
'#maxlength' => 64,
// Required is forced OFF because this is technically part of street.
);
case 'city':
return array(
'#type' => 'textfield',
'#title' => t('City'),
'#default_value' => $obj != '' ? $obj : location_alter('city'),
'#size' => 64,
'#maxlength' => 64,
'#description' => NULL,
'#attributes' => NULL,
'#required' => ($a4 == 2),
);
case 'province':
drupal_add_js(drupal_get_path('module', 'location') .'/location_autocomplete.js');
$country = $a5['country'] ? $a5['country'] : variable_get('location_default_country', 'us');
return array(
'#type' => 'textfield',
'#title' => t('State/Province'),
'#autocomplete_path' => 'location/autocomplete/'. $country,
'#default_value' => $obj != '' ? $obj : location_alter('province'),
'#size' => 64,
'#maxlength' => 64,
'#description' => NULL,
// Used by province autocompletion js.
'#attributes' => array('class' => array('location_auto_province')),
'#required' => ($a4 == 2),
);
case 'country':
// Force default.
if ($a4 == 4) {
return array(
'#type' => 'value',
'#value' => variable_get('location_default_country', 'us'),
);
}
else {
$options = array_merge(array('' => t('Please select'), 'xx' => 'NOT LISTED'), location_get_iso3166_list());
return array(
'#type' => 'select',
'#title' => t('Country'),
'#default_value' => $obj,
'#options' => $options,
'#description' => NULL,
'#required' => ($a4 == 2),
// Used by province autocompletion js.
'#attributes' => array('class' => array('location_auto_country')),
);
}
break;
case 'postal_code':
return array(
'#type' => 'textfield',
'#title' => t('Postal code'),
'#default_value' => $obj != '' ? $obj : location_alter('postal_code'),//$location_alter['postal_code'],//location_alter('postal_code'),
'#size' => 16,
'#maxlength' => 16,
'#required' => ($a4 == 2),
);
}
break;
case 'isunchanged':
switch ($a3) {
case 'lid':
// Consider 0, NULL, and FALSE to be equivilent.
if (empty($obj[$a3]) && empty($a4)) {
return TRUE;
}
break;
case 'country':
// Consider ' ' and '' to be equivilent, due to us storing country
// as char(2) in the database.
if (trim($obj[$a3]) == trim($a4)) {
return TRUE;
}
break;
case 'province_name':
case 'country_name':
case 'map_link':
case 'coords':
// Always considered unchanged.
return TRUE;
}
break;
}
}