function profile2_page_user_view in Profile 2 7.2
Implements hook_user_view().
Displays the links to profile pages.
File
- contrib/
profile2_page.module, line 269 - Adds separate pages for viewing and editing profiles.
Code
function profile2_page_user_view($account, $view_mode, $langcode) {
$links = array();
foreach (profile2_get_types() as $type_name => $type) {
if ($type->data['use_page'] && ($profile = profile2_load_by_user($account, $type_name))) {
if (profile2_access('view', $profile)) {
$links[] = array(
'#type' => 'link',
'#title' => $type
->getTranslation('label'),
'#href' => profile2_page_get_base_path($type) . "/{$account->uid}",
'#prefix' => '<div class = "profile-page-link">',
'#suffix' => '</div>',
'#options' => array(),
);
}
}
}
if (!empty($links)) {
$title = array(
'#type' => 'html_tag',
'#tag' => 'h3',
'#value' => t('Profile pages'),
);
$account->content['profile_pages'] = array(
'#type' => 'html_tag',
'#tag' => 'section',
'#attributes' => array(
'class' => 'profile-page-links',
),
'#value' => drupal_render($title) . drupal_render($links),
);
}
}