Using drupal 7, Views 3, I have a function (present on Leaflet Module) which takes only 2 parameters. I use this hook function to print resulting points from view in different colors
//Allow modules to alter the points data while rendering a leaflet views row.
MY_MODULE_leaflet_views_alter_points_data_alter ($result, &$points)
{
if (isset($result->number))
{
// Add number value to every points data entry, if present.
array_walk($points, function(&$point, $key, $number) {
$point['number'] = $number;
}, $result->number);
}
}
I am trying to use this hook to take variables from outside the function. For example:
$data='heeeello';
MY_MODULE_leaflet_views_alter_points_data_alter ($result, &$points)
{
echo $data;
}
Just returns NULL. Tried setting it up as Global (which should already be, but just in case), also variable_set($data,'hello')... no success.
Executing the function passing the params works neither:
MY_MODULE_leaflet_views_alter_points_data_alter ($result, &$points,$param)
{
echo $param;
}
thanks in advance
EDIT
I want to populate an external array based on the data processed by my hook (see below MY_MODULE_leaflet_views_alter_points_data_alter)
This final array has to contain unique values. On standard PHP I would access the external array and populate recursively it but I have problems accessing this array via my hook.
Using global doesn't work, but it works using variable_set and variable_get, but it means that each time the hook access the variable (variable_get(param)), the array starts empty again.
$array = array();
variable_set('my_array', $array);
//testing global, doesnt work
$test=array();
MY_MODULE_leaflet_views_alter_points_data_alter ($result, &$points) {
global $test;
var_dump($test); //NULL
$my_array= variable_get('my_array');
//I will get allways an empty array... even if its later correctly populated
//fetching results from the hook
$name=$result->name;
if (!in_array($name,$my_array))
{
array_push($my_array,$name);
}
//plots just a value (array is not recursively populated, as allways start empty inside the hook)
var_dump($my_array);
}