You are here

function content_multigroup_token_values in Custom Formatters 6

Implements hook_token_values().

File

includes/content_multigroup.inc, line 129
Provides Custom Formatters integration with the Content Multigroup module.

Code

function content_multigroup_token_values($type, $object = array()) {
  $values = array();
  if ($type == 'field') {
    foreach (fieldgroup_groups() as $groups) {
      foreach ($groups as $group) {
        if ($group['group_type'] == 'multigroup') {
          foreach ($group['fields'] as $field) {
            if (isset($object[0][$field['field_name']]) && function_exists($function = "{$field['widget_module']}_token_values")) {
              $tokens = $function($type, array(
                $object[0][$field['field_name']],
              ));
              foreach ($tokens as $key => $value) {
                $values["content_multigroup-{$field['field_name']}-{$key}"] = $value;
              }
            }
          }
        }
      }
    }
  }
  return $values;
}