#368559 by moshe weitzman: Return renderable arrays from profile pages.
parent
957feb0cd3
commit
d91848a92a
|
@ -40,7 +40,7 @@ function user_theme() {
|
|||
'template' => 'user-picture',
|
||||
),
|
||||
'user_profile' => array(
|
||||
'arguments' => array('account' => NULL),
|
||||
'arguments' => array('elements' => NULL),
|
||||
'template' => 'user-profile',
|
||||
'file' => 'user.pages.inc',
|
||||
),
|
||||
|
|
|
@ -148,15 +148,35 @@ function user_logout() {
|
|||
|
||||
/**
|
||||
* Menu callback; Displays a user or user profile page.
|
||||
*
|
||||
* The $page['content'] array for user profile pages contains:
|
||||
*
|
||||
* - $page['content']['Profile Category']:
|
||||
* Profile categories keyed by their human-readable names.
|
||||
* - $page['content']['Profile Category']['profile_machine_name']:
|
||||
* Profile fields keyed by their machine-readable names.
|
||||
* - $page['content']['user_picture']:
|
||||
* User's rendered picture.
|
||||
* - $page['content']['summary']:
|
||||
* Contains the default "History" profile data for a user.
|
||||
* - $page['content']['#account']:
|
||||
* The user account of the profile being viewed.
|
||||
*
|
||||
* To theme user profiles, copy modules/user/user-profile.tpl.php
|
||||
* to your theme directory, and edit it as instructed in that file's comments.
|
||||
*/
|
||||
function user_view($account) {
|
||||
drupal_set_title($account->name);
|
||||
// Retrieve all profile fields and attach to $account->content.
|
||||
user_build_content($account);
|
||||
|
||||
$build = $account->content;
|
||||
$build += array(
|
||||
'#theme' => 'user_profile',
|
||||
'#account' => $account,
|
||||
);
|
||||
|
||||
// To theme user profiles, copy modules/user/user_profile.tpl.php
|
||||
// to your theme directory, and edit it as instructed in that file's comments.
|
||||
return theme('user_profile', $account);
|
||||
return drupal_get_page($build);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,12 +188,14 @@ function user_view($account) {
|
|||
* @see user-picture.tpl.php
|
||||
*/
|
||||
function template_preprocess_user_profile(&$variables) {
|
||||
$account = $variables['elements']['#account'];
|
||||
|
||||
$variables['profile'] = array();
|
||||
// Sort sections by weight
|
||||
uasort($variables['account']->content, 'element_sort');
|
||||
uasort($account->content, 'element_sort');
|
||||
// Provide keyed variables so themers can print each section independently.
|
||||
foreach (element_children($variables['account']->content) as $key) {
|
||||
$variables['profile'][$key] = drupal_render($variables['account']->content[$key]);
|
||||
foreach (element_children($account->content) as $key) {
|
||||
$variables['profile'][$key] = drupal_render($account->content[$key]);
|
||||
}
|
||||
// Collect all profiles to make it easier to print all items at once.
|
||||
$variables['user_profile'] = implode($variables['profile']);
|
||||
|
|
Loading…
Reference in New Issue