Hi,
When using more than 1 profile2 type I've noticed that when the profiles are displayed on the user page /user/username, the profile2 content isn't displayed according to the weight column on each profile type row in profiletype table. In order to get round this I have done changed the following
function profile2_user_view($account, $view_mode, $langcode) {
foreach (profile2_get_types() as $type => $profile_type) {
if ($profile_type->userView && $profile = profile2_load_by_user($account, $type)) {
if (profile2_access('view', $profile)) {
$account->content['profile_' . $type] = array(
'#type' => 'user_profile_category',
'#title' => $profile->label,
'#prefix' => 'type . '">',
);
$account->content['profile_' . $type]['view'] = $profile->view('account');
}
}
}
}
to
function profile2_user_view($account, $view_mode, $langcode) {
$profile2 = profile2_get_types();
usort($profile2, 'profile2_sortByOrder');
foreach ($profile2 as $a_profile){
$profile_array[$a_profile->type] = $a_profile;
}
foreach ($profile_array as $type => $profile_type) {
if ($profile_type->userView && $profile = profile2_load_by_user($account, $type)) {
if (profile2_access('view', $profile)) {
$account->content['profile_' . $type] = array(
'#type' => 'user_profile_category',
'#title' => $profile->label,
'#prefix' => 'type . '">',
);
$account->content['profile_' . $type]['view'] = $profile->view('account');
}
}
}
}
As you can see, this is a complete bodge but it at least does what I want it to do for now. It seems like display weight should be defined within each profile2 type and that when rendered in the user page they should be ordered by that weight value.
Comments
Comment #1
dman commentedTry this #894904: Allow weighting profile types