I have a block with invocation code inside(it invokes js code from OpenX ads server), my site is responsive and this block get cloned(with jquery .clone()
function) on ipad or iphone version of the site. So to avoid calling the invocation js code 2 times i need to set js variable (like this - > window.isScriptLoaded = FALSE
) and then inside my block i can easy do next thing:
if (window.isScriptLoaded == FALSE) {
window.isScriptLoaded = TRUE;
//invocation code...
}
in this case all working fine, i can easy add this variable to any js file in drupal.
But in my case admin
can add new block and insert new invocation code - SO I need to generate window.isScriptLoaded2
and output this variable BEFORE code in block is loaded
i tried next thing
function HOOK_page_alter(&$page) {
//get all the variables
//i generate my variables in database
$var = db_query("SELECT * FROM {banners}")->fetchAll();
$full_array = array();
foreach($var as $object) {
//for example Anyvariable = FALSE;
$array[$object->name] = $object->value;
}
drupal_add_js(array('common' => array(
'vars' => $array,
)), 'setting');
}
this works but, code in block is loaded before drupal.settings.vars.Anyvariable
is loaded.
So my variables is always false