Attached is code to integrate with Panels 3. Included is a location context, a location from node relationship, and a country name content.

CommentFileSizeAuthor
location_panels.zip4.67 KBwwhurley

Comments

aelling’s picture

I am just needing this! Is there are chance that this plugin will support location provinces so a province context would be available?

wwhurley’s picture

What you would do is modify plugins/context/location.inc where it has the following:

/**
 * Provide a list of ways that this context can be converted to a string.
 */
function location_panels_context_location_convert_list() {
	return array(
  	'country_code'		=> t('Country Code'),
	'country_name'		=> t('Country Name'),
	);
}

/**
 * Convert a context into a string.
 */
function location_panels_context_location_convert($context, $type) {
	switch ($type) {
		case 'country_code':
			return $context->data['country'];
		case 'country_name':
			return $context->data['country_name'];
	}
}

That controls what elements of the context are exposed. You would add 'province' and 'province_name' to the array returned by location_panels_context_location_convert_list and then add those cases to the switch in location_panels_context_location_convert returning $context->data['province'] or ['province_name'] as appropriate as $context->data is a location array loaded location_load_location.

I also notice a bug in location_panels_context_create_location, I have $data = location_load_location($nid), which should probably be $data = location_load_location($lid)

aelling’s picture

Ok great! Thanks for the response and explanation.

yesct’s picture

dww’s picture

Status: Active » Closed (duplicate)

Thanks, I need something just like this. However, let's move discussion over to the original issue for this feature: #487790: Panels integration