Created
January 17, 2014 17:18
-
-
Save kirikintha/8477420 to your computer and use it in GitHub Desktop.
This is just a quick example of using the drupal hook_library. For "vendor" libraries, but those into your /sites/all/libraries path, however for this particular example, using google maps, we have two files that that are needed to invoke the google maps v3 api. This puts everything into the footer, in order and allows Drupal to aggregate the fi…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
** | |
* Implements hook_library | |
*/ | |
function my_module_api_library() { | |
//Google API key. | |
$key = 'mygoogleapikey'; | |
$libraries = array(); | |
$libraries['my-module'] = array( | |
'title' => 'My Module', | |
'website' => 'http://my-site.localhost', | |
'version' => '1.0', | |
'js' => array( | |
//Google maps. | |
'https://maps.googleapis.com/maps/api/js?key='.$key.'&sensor=false' => array( | |
'scope' => 'footer', | |
'weight' => -20, | |
'group' => JS_LIBRARY, | |
'type' => 'external' | |
), | |
//Info Box for google maps. | |
PROPERTY_API_MODULE_PATH .'/includes/js/infobox.js' => array( | |
'scope' => 'footer', | |
'weight' => 0, | |
'group' => JS_DEFAULT, | |
), | |
//Module javascript. | |
PROPERTY_API_MODULE_PATH .'/includes/js/my-module.js' => array( | |
'scope' => 'footer', | |
'weight' => 1, | |
'group' => JS_DEFAULT, | |
), | |
), | |
); | |
return $libraries; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment