diff --git a/modules/farm/farm_map/farm_map.api.php b/modules/farm/farm_map/farm_map.api.php index d2c3a260..0a8badb5 100644 --- a/modules/farm/farm_map/farm_map.api.php +++ b/modules/farm/farm_map/farm_map.api.php @@ -21,6 +21,20 @@ * Hooks that can be implemented by other modules in order to extend farm_map. */ +/** + * Perform logic when a map is viewed. + * + * @param $name + * The map name. + * @param $element + * The map element. + */ +function hook_farm_map_view($name, $element) { + + // Add a farmOS map behavior JS file. + drupal_add_js(drupal_get_path('module', 'mymodule'), 'mymodule.mybehavior.js'); +} + /** * Extract geometries from an entity. * diff --git a/modules/farm/farm_map/farm_map.module b/modules/farm/farm_map/farm_map.module index be0b5aef..7d4ff134 100644 --- a/modules/farm/farm_map/farm_map.module +++ b/modules/farm/farm_map/farm_map.module @@ -7,6 +7,16 @@ include_once 'farm_map.features.inc'; include_once 'farm_map.geo.inc'; +/** + * Implements hook_hook_info(). + */ +function farm_map_hook_info() { + $hooks['farm_map_view'] = array( + 'group' => 'farm_map', + ); + return $hooks; +} + /** * Implements hook_permission(). */ @@ -133,6 +143,9 @@ function theme_farm_map(&$vars) { // Add farm_map.css. drupal_add_css(drupal_get_path('module', 'farm_map') . '/css/farm_map.css'); + // Allow other modules to perform logic. + module_invoke_all('farm_map_view', $map_name, $element); + // Return a simple div with attributes. return ''; }