Skip to content

Instantly share code, notes, and snippets.

@and1truong
Created July 23, 2012 10:05
Show Gist options
  • Select an option

  • Save and1truong/3162929 to your computer and use it in GitHub Desktop.

Select an option

Save and1truong/3162929 to your computer and use it in GitHub Desktop.
Fix OG label - #drupal #og
<?php
/**
* Implements hook_entity_load().
*
* @param type $entities
* @param type $type
* @return type
*/
function HOOK_entity_load($entities, $type) {
if ($type === 'group') {
return HOOK_entity_load__group($entities);
}
}
/**
* Fix Group label.
*
* @see kiqar_town_entity_load().
*/
function HOOK_entity_load__group($groups) {
$s = db_select('field_data_title_field', 'tf');
$s->innerJoin('og', 'og', 'og.etid = tf.entity_id AND og.entity_type = :node', array(':node' => 'node'));
$s->condition('tf.language', $GLOBALS['language']->language);
$s->condition('og.gid', array_keys($groups));
$s->fields('og', array('gid'));
$s->fields('tf', array('title_field_value'));
$labels = $s->execute()->fetchAllKeyed();
foreach ($labels as $gid => $label) {
$groups[$gid]->label = $label;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment