You are here

function redhen_relation_page_title in RedHen CRM 7

Custom title callback for relation pages.

1 string reference to 'redhen_relation_page_title'
redhen_relation_menu_alter in modules/redhen_relation/redhen_relation.module
Implements hook_menu_alter().

File

modules/redhen_relation/redhen_relation.module, line 170
Redhen CRM Relation Module.

Code

function redhen_relation_page_title($relation) {
  $endpoints = field_get_items('relation', $relation, 'endpoints');
  $redhen_entities = array(
    'redhen_contact',
    'redhen_org',
  );
  if (!in_array($endpoints[0]['entity_type'], $redhen_entities) || !in_array($endpoints[1]['entity_type'], $redhen_entities)) {
    return relation_ui_page_title($relation);
  }
  $relation_type = relation_type_load($relation->relation_type);
  foreach ($endpoints as $endpoint) {
    if ($endpoint['r_index'] == 0) {
      $label1 = entity_load_single($endpoint['entity_type'], $endpoint['entity_id'])
        ->label();
    }
    if ($endpoint['r_index'] == 1) {
      $label2 = entity_load_single($endpoint['entity_type'], $endpoint['entity_id'])
        ->label();
    }
  }
  return t('@type between @label1 and @label2', array(
    '@type' => relation_get_type_label($relation_type),
    '@label1' => $label1,
    '@label2' => $label2,
  ));
}