Allow other modules to perform logic when a map is rendered via hook_farm_map_view().
This commit is contained in:
parent
c0fa34f1ae
commit
7361a17490
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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 '<div' . drupal_attributes($element['#attributes']) . '></div>';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue