global variable question
I am trying to display a flot graph (with flot module) to do this i have to pass data from php to javascript.
in my theme function i added
<?php
$paretoData = array(array(0,0), array(1,1), array(2,2), array(3,3), array(4,4));
drupal_add_js(array('data_analysis' => array(
'data' => $paretoData,
'text' => 'i am js coming from php',
)), 'setting');
?>Then i use Drupal.settings.data_analysis.data in my javascript to get the data. So far so good.
Now i want to change the value of $paretoData in other functions (based on a form and data from a database).
However i can't seem to write or read this value outside the theme function.
i tried declaring a global variable:
<?php global $paretoData; ?> at the top of the .module
and using <?php global $paretoData; ?> in all functions where i want to read or write to/from this variable.
also read and tried this: http://drupal.org/node/52649 but i can't get it working
a set_data($newdata) and get_data() function would be perfect, how can i implement this??
