By j0k3z on
I am currently using OpenLayers to show Node locations on a map. I am using a custom map marker and currently all nodes show the same marker. The code I am using is as follows
$style = array();o
if ($record->node_type == 'business') {
$style['externalGraphic'] = base_path().'images/map_blue.png';
} else {
$style['externalGraphic'] = base_path().'images/map_blue.png';
}
$style['graphicHeight'] = 24;
$style['graphicWidth'] = 24;
$style['graphicOpacity'] = 1;
$style['graphicYOffset'] = -22;
return $style;
This code obviously returns the same icon for all nodes. What I would like to do is add a simple checkbox field type on this node type, and if I check the box on that node then I want the marker to be a different image on the map.
I believe instead of $record->node_type == I would need something like if $field->field_name =="1" but I am not exactly sure as I havent been able to get it to work.
PM me if you can help
Comments
$50?
$50?
Here's a way
There are a lot of ways to access a field. I have been told this isn't the proper drupal 7 way, but it is simple.
For a field called tickets_sold (machine name):
Assuming that record is the node,
$record->field_tickets_sold[LANGUAGE_NONE][0]['value'] == 'whatever value you are checking for'
or
$record->field_ticket_price['und'][0]['value'] == 'the check value'
The other way requires a function, but it looks like you use drupal 6 anyway. It'll probably work, or some code along those lines.
Money por favor? :)