You are here

function profile2_preprocess_page in Profile 2 7

Same name and namespace in other branches
  1. 7.2 profile2.module \profile2_preprocess_page()

Implements hook_preprocess_page().

Fix the page titles on the profile2 edit tabs. We want the titles to be the full profile label, giving the user name & profile name.

File

./profile2.module, line 1229
Support for configurable user profiles.

Code

function profile2_preprocess_page(&$vars) {

  // This is true when editing a profile in a tab.
  if (!empty($vars['page']['content']['system_main']['#user_category'])) {
    $ptype = $vars['page']['content']['system_main']['#user_category'];
    if (!empty($vars['page']['content']['system_main']["profile_{$ptype}"])) {
      $item = $vars['page']['content']['system_main']["profile_{$ptype}"];

      // If we've found an item, and it has a profile2 entity, display the title.
      if (!empty($item['#entity'])) {
        $vars['title'] = $item['#entity']
          ->label();
      }
    }
  }
}