Theming locations in the nodetype.tpl.php works great for all variables except $map_link. It's available in location.tpl.php but not passed to the node templates. Is there a way to access this variable through a function call? The gmap_simple_map function works great for embedding a map in the node but for directions I need to print out the link back to Google. This would be a helpful feature if not already implemented.

Comments

teodor.sandu’s picture

I see no-one helped you, did you reach a solution? If so, please share with the community.

What I'd suggest is to use template.php - create a theme_preprocess_node_type() function (with your own theme name and node type of course) to inject that variable in the .tpl file. The Theme Developer plugin will show you exactly what's the function name. Have a dpm() of your first argument to see what variables you do get and what you can use to get the data you want. Then save it in the argument (it's passed by reference) and you'll have it in the .tpl for use.

I hope that was clear enough.

leenwebb’s picture

In case anyone else comes across this -- I was also able to put this into my node.tpl and display the map link:

$map_link = location_map_link($variables['location']);
print $map_link;	
brentratliff’s picture

Thanks guys. I ended up creating a view with the node id as the default argument and then attaching it to the node with views attach. This way I could use Display Suite plugin to layout the bubble as well.

megan_m’s picture

In Drupal 7, try:

  $map_link = location_map_link($content['field_location'][0]['#location']);
  print $map_link;

or just:

print location_map_link($content['field_location'][0]['#location']);