【问题标题】:How to display the email in View page of Drupal7如何在 Drupal 7 的查看页面中显示电子邮件
【发布时间】:2016-05-23 11:52:43
【问题描述】:

建议我如何在 Drupal7 的 [查看页面] 中查看编辑页面电子邮件 ID

【问题讨论】:

    标签: php drupal drupal-7


    【解决方案1】:

    将文件 /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”。

    【讨论】:

      【解决方案2】:
      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,
         );
      
       }
      

      我通过这种方式得到了解决方案。没事吧。

      【讨论】:

        【解决方案3】:

        与从自定义主题(自定义我建议的模板)执行此操作相比,从自定义模块执行此操作的另一个选项是实现 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 合作。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-03-11
          • 1970-01-01
          • 2016-01-12
          相关资源
          最近更新 更多