Created
July 18, 2011 06:40
-
-
Save nigelheap/1088698 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Loads a group ID from a node ID | |
*/ | |
function artroom_ui_og_load_from_nid($nid) { | |
static $groups; | |
if (empty($groups)) { | |
$q = db_select('og'); | |
$q->fields('og', array('gid', 'etid')); | |
$q->condition('entity_type', 'node', '='); | |
foreach ($q->execute()->fetchAll() as $row) { | |
$groups[$row->etid] = $row->gid; | |
} | |
} | |
return og_load($groups[$nid]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment