0

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

function HOOK_preprocess_views_view(&$vars) {
  if ($vars['view']->name == 'MYVIEWSNAME') {
    $nid = $vars['view']->result[0]->nid;
    $node = node_load($nid);
    $og_id = $node->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.

2
  • What is it you're trying to do? Mar 5 '14 at 22:19
  • I want to get some information about the nodes of a view. And print them inside the view. For example into the header section.
    – Sven
    Mar 6 '14 at 13:59
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.