Get id of an organic group inside a view How can i get the organic group id inside a view?
I tried to get it like this:

function HOOK_preprocess_views_view(&amp;$vars) {
  if ($vars['view']-&gt;name == 'MYVIEWSNAME') {
    $nid = $vars['view']-&gt;result[0]-&gt;nid;
    $node = node_load($nid);
    $og_id = $node-&gt;og_group_ref['und'][0]['target_id'];
    dpm($og_id); 
  }
}


This is printing the correct id to my devel debug,
but i cant access $og_id in my view-template.

Or maybe you got an other solution to create the /node/add/document .. link.
Do you have a corresponding template file in your sub-theme? 

Themes cannot have a preprocess function without a corresponding .tpl.php file

https://drupal.org/node/258089