Last active
August 29, 2015 14:16
-
-
Save keeprock/3990dc66d1f96d025ce8 to your computer and use it in GitHub Desktop.
Access variables from PHP in Javascript
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
drupal_add_js(array('VAR_JS' => $VAR_PHP), 'setting'); | |
// Alternative | |
drupal_add_js(array('CUSTOM_MODULE' => array('KEY' => 'value')), 'setting'); |
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
if(settings.VAR_JS !== undefined){ | |
} | |
// Alternative | |
Drupal.settings.CUSTOM_MODULE.KEY; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment