I've got a hook_node_view which I'm trying to add a property of the node to an array that I have created in the Drupal.settings
drupal_add_js(array('embedded_videos'=>array()));
So in the node_view I can do
function mymod_node_view($node, $view_mode, $langcode) {
if($node->type == 'video'){
drupal_add_js(array(
'vimn_video' => array('embedded_videos' => $node->nid,
),
),
'setting');
}
But this overwrites what is in there, whereas I want to add to the array. Because this node_view is running multiple times as I have 2 video nodes embedded into an article node.
Any ideas appreciated. I am new to the usage of Drupal.settings javascript api.
edit: The issue was that I needed to put $node->nid into an array array($node->nid), then it will add an item to the array rather than overwriting it.