Skip to content

Instantly share code, notes, and snippets.

@davestacey
Last active August 29, 2015 14:06
Show Gist options
  • Save davestacey/569ae271b32b0cf7969c to your computer and use it in GitHub Desktop.
Save davestacey/569ae271b32b0cf7969c to your computer and use it in GitHub Desktop.
maps.module - Custom Drupal module to control leaflet and geoJSON data
<?php
function maps_preprocess_page(&$variables) {
//dpm("es_maps_preprocess_page");
// Set full basepath for JS
global $base_path;
$my_base_path = $GLOBALS['base_url'] . $GLOBALS['base_path'] . drupal_get_path('module', 'es_maps');
//dpm('$my_base_path', $my_base_path);
// pass full module path to settings for JS
$my_settings = array(
'basePath' => $my_base_path,
);
drupal_add_js(array('customSettings' => $my_settings), 'setting');
if (isset($variables['node']) && $variables['node']->type == 'map_geojson') {
//dpm("map_geojson module");
// Add js custom
drupal_add_js(drupal_get_path('module', 'es_maps') . '/es_maps.js');
$variables['scripts'] = drupal_get_js();
}//if (isset
}//function es_maps_preprocess_page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment