I am using the Location Taxonomy module to allow users to select the location from the taxonomy listing. I have them adding the location information on the taxonomy term level but I do not see how I am able to display that information on the node level. The location information is not found in the $node-taxonomy array as I'd expect.

What am I missing?

Comments

interestingaftermath’s picture

sorry for the bump but I could really use a reply. I don't see what else you would need Location Taxonomy if not to display it on the node you're tagging with the taxonomy...

rooby’s picture

Hey Ryan,

The location taxonomy module only really links terms to locations. It doesn't deal with display. Feel free to put in a feature request for such things.
The only thing it does have code for is to link to relevant terms for location search results when using location search (Although from a quick look at the code just now I don't believe that functionality will work either).

You can customise your node.tpl.php to print the locations.
You can get the locations from the term ID by doing something along the lines of:

<?php
  // Get the locations for the term.
  $locations = location_load_locations('taxonomy:' . $term_id, 'genid');
  // Get the location settings for the vocabulary.
  $settings = variable_get('location_taxonomy_' . $vocabulary_id, array());
  // Get the hide values from the settings so you only show the relevant parts of the locations.
  $hide = array_keys(array_filter($settings['display']['hide']));
  // Output the locations.
  print theme('locations', $locations, $hide);
?>

You can also use theme('location', $location, $hide) to print a single location.

rooby’s picture

Although you probably want to do that in your template_preprocess_node and then print in your tpl.

interestingaftermath’s picture

Thanks! This works great and it's exactly what I was looking for. I knew there had to be a way to call the taxonomy data but I just couldn't figure it out.

For any stumbling across this thread, here's my end result (before moving into my template_preprocess_node function. This will print out the location info + a map if you have the gmap module installed. This is prior to me theming it so it's basically just a data dump.

		// Get the locations for the term.
		$locations = location_load_locations('taxonomy:' . 8, 'genid');
		// Get the location settings for the vocabulary.
		$settings = variable_get('location_taxonomy_' . 3, array());
		// Get the hide values from the settings so you only show the relevant parts of the locations.
		$hide = array_keys(array_filter($settings['display']['hide']));
		// Output the locations.
		print theme('locations', $locations, $hide);
		
		dpm($locations);
		
		$info .= $locations[0]['name'] . '<br />';
		$info .= $locations[0]['street'] . '<br />';
		$info .= $locations[0]['city'].', '.$locations[0]['province'].$locations[0]['postal_code'];
		
		$lat = $locations[0]['latitude'];
		$long = $locations[0]['longitude'];
		print gmap_simple_map($lat, $long, '', $info, 5, '300px', '250px', false, '');
	
rooby’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

Stomper’s picture

I have the module enabled and am trying to figure out how to use the Location Taxonomy module. I have taxonomy vocabulary with state-city-campus, I would like to link the campus to a state-city in the Location module.

Could you please give a quick rundown on how to do so. I do not want users to control how the Taxonomy term is linked to Location. I would like the admin (myself) to make the connection, once, so if a user selects a campus from the vocabulary, the state and city location will be displayed from the Location module. Additionally, if a user selects state and city from Location first, then the associated taxonomy terms will be linked.

Displaying is secondary, I just want to link them for now. A guide would be appreciated.

Thanks

protools’s picture

why location block don't work on term page? i use Location Taxonomy, set location data for term, but on term page block location display none ... use views for this simple task?

Stomper’s picture

I found how to do it, the location fields are on each term's configuration page within the taxonomy admin menu. Is there anyway to import bulk location data via taxonomy csv?