【发布时间】:2016-05-23 11:52:43
【问题描述】:
【问题讨论】:
【问题讨论】:
将文件 /modules/user/user-profile.tpl.php 复制到您主题的模板文件夹中,然后根据您的需要对其进行自定义。
你可以在那里转储 $user 变量,例如
<div class="profile"<?php print $attributes; ?>>
<?php print render($user_profile); ?>
<?php var_dump($user); ?>
</div>
电子邮件地址值为 $user->mail。
不要忘记在对主题进行任何编辑后运行“drush cc theme-registry”。
【讨论】:
function alt_user_view($account) {
global $user;
$account->content['email']['display'] = array(
'#type' => 'user_profile_item',
'#title' => t('E-mail Id:'),
'#markup' => $account->mail . l(' (edit)', 'emailedit/' . $user->uid . '/' ),
'#attributes' => array('class' => array('field-label')),
'#weight' => 10,
);
}
我通过这种方式得到了解决方案。没事吧。
【讨论】:
与从自定义主题(自定义我建议的模板)执行此操作相比,从自定义模块执行此操作的另一个选项是实现 hook_user_view_alter,您可以参考https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_view_alter/7.x 的文档
文档中提到的第三个选项是实现另一个名为 hook_preprocess_user_profile() 的钩子,但该钩子应该在自定义主题中。
所以这完全取决于您是否使用模块或主题,使用主题挂钩或主题模板。很高兴与 Drupal 合作。
【讨论】: