Created
July 23, 2012 10:05
-
-
Save and1truong/3162929 to your computer and use it in GitHub Desktop.
Fix OG label - #drupal #og
This file contains hidden or 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 | |
| /** | |
| * 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