I know it's perfectly possible to pass PHP variables to JS but what if the JS file is initiated from the theme.info file? Can you access it in template.php or? Please some advice..
Thanks!
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityYou don't access the Javascript file in PHP, rather, you tell Drupal to send values to Javascript variables and then access those from your Javascript files. You would use drupal_add_js.
For example, in template.php add:
drupal_add_js(array('myModule' => array('key' => 'value')), 'setting');
Then in your Javascript file, you can access that variable as:
Drupal.settings.myModule.key