Hi there,

I am using this CCK field with nodeprofile. What I would like to do is set the value of this field by joining the address values in 4 or 5 other text and select fields on the nodeprofile form. e.g Address Line 1 + Address Line 2 + City + Province etc...

What I really want is this to show up on the users profile so the administrator can click on the link and get a Google map of the the users business address for deliveries. So far I have been trying to set the default value of the field by putting the following in the default value PHP code section.

return array(
0 => array('value' => $node->$field_address_line_1[0]['value'])
);

I'm no PHP wizard so it's trial and error for me at the moment. I tried that to see if I could even get the first field value in to the map link field, but that didn't work for me. What I figure is once I figure out how to get one variable in there I can concatenate all the variables I need in to one.

Is this possible?

Thanks,
Mat

Comments

MichaelCole’s picture

Hi Marc,

Good question. Did you figure out a solution?

Check out the "Devel Module". It creates a tab on each node so you can look at it's variables.

See here: http://drupalmodules.com/module/devel

Best luck,

Mike

matshep1’s picture

Component: Code » Miscellaneous
Status: Active » Fixed

In the end I could not achieve this with the CCK link to map field. Just in case this would be of any help to anyone else, here is how I solved my problem.

I abandoned the idea of using the CCK link to map field for this purpose. I think by trying to populate the default value of the 'link to map' field by using the 'php code' section and referencing other field values from the user profile, I am in fact calling values before they exist during the user profile setup.

I hope this makes sense!:

What I really wanted was a link to show up to a google map of the users address in the completed user profile (as viewed in the 'my account' section). I achieved this by using the contemplate module to add to my user profile body template as follows:

<?php print $node->body ?>
<?php
$maplink = $node->field_address_line_1[0]['value'];

if($node->field_address_line_2_0[0]['value'] >"" ){
$maplink = $maplink.", ".$node->field_address_line_2_0[0]['value'];
}

$maplink = $maplink.", ".$node->field_towncity[0]['value'];

if($node->field_county[0]['value'] != "Other"){
$maplink = $maplink.", ".$node->field_county[0]['value'];
} else {
$maplink = $maplink.", ".$node->field_county_if_other[0]['value'];
}

if($node->field_postal_code[0]['value'] > ""){
$maplink = $maplink.", ".$node->field_postal_code[0]['value'];
}

$maplink = $maplink.", ".$node->field_country[0]['value'];

print "<fieldset><legend>View on Map</legend><a href='http://maps.google.com/maps?q=".$maplink."' target='_blank'>".$maplink."</a></fieldset>";

?>

What I am doing here is joining all the address strings together (provided they are not blank or irrelevant) and then putting the resulting address string in to a google map query link. This provides me with a nice little link at the bottom of the user profile to view a google map of the address the user entered.

Mat :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.