Is there any way to add some variables to Drupal.settings without drupal_add_js (with setting argument).

I'm creating a site that has a custom ctools popup style but I'm not feeling good with drupal_add_js. How can I add this JavaScript snippet to the page using the theme's .info page ? I'm not sure how can I merge my custom variables (literally, they are just static) to Drupal.settings so ctools module can pick them up as it was added via regular drupal_add_js call.

Thank you in advance.

  • No there's no way to do that, you need to use drupal_add_js or an #attached property on a render array
    – Clive
    Sep 26, 2013 at 7:55
  • Ohh.. I really wish Drupal has a little more magic to do that. Anyway, thank you very much for your help Clive.
    – AKS
    Sep 26, 2013 at 7:59
  • No worries, I haven't put it in as an answer 'cos I'm hoping someone will know some sort of dark magic to prove me wrong :)
    – Clive
    Sep 26, 2013 at 8:01
  • With using JS injector you can add js code directly on the UI, and it provides conditionnals conditions (match pages urls)
    – pico34
    Sep 26, 2013 at 8:08
  • @pico34 Can you use JS injector to manipulate Drupal.settings? That would be pretty cool
    – Clive
    Sep 26, 2013 at 8:15

1 Answer 1


Maybe I am missing a point to the question, but you should be able to do

scripts[] = path/to/your/script.js

in the .info file of your theme. And within the script file something like

(function ($) {
$(document).ready(function () {
    Drupal.settings.yoursetting = {};
    Drupal.settings.yoursetting.property = some_value;

or use the Drupal.behaviors convention.

  • YOU ARE GENIUS WAYNE! This worked perfectly. Thank you very very much.
    – AKS
    Sep 27, 2013 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.