Drupal 7:用户注册页面的模板?

时间:2012-10-10 16:22:46

标签: drupal drupal-7 drupal-theming drupal-templates

如何为用户注册页面制作模板?我想主题整个页面,而不仅仅是表单。我已经尝试了page--user-register.tpl.php,但这不起作用。

5 个答案:

答案 0 :(得分:4)

您想使用page--user--register.tpl.php代替page--user-register.tpl.php

page--user-register.tpl.php更改了网页user-register的模板,而page--user--register.tpl.php更改了网页user/register的模板。

答案 1 :(得分:3)

我建议使用theme developer module

它将显示任何给定页面的所有模板建议,以及调用它们的内容。还要确保清除缓存。

另外This is a great resource

答案 2 :(得分:3)

开箱即用的Drupal不会为注册表单提供任何模板建议。您需要编写一个自定义模块来添加它。你可以这样做:

/**
 * Implements hook_theme().
 */
function mymodule_theme() {
  $items = array(
    'user_register_form' => array(
      'render element' => 'form',
      'template' => 'templates/user-register-form',
    ),
  );
  return $items;
}

然后你在mymodule / templates中有一个名为user-register-form.tpl.php的模板,您可以在主题中自定义或覆盖它。

答案 3 :(得分:1)

Drupal 7

将此代码添加到主题目录中的template.php。

    function yourtheme_theme() {
      return array(
        'user_login' => array(
          'template' => 'user-login',
          'arguments' => array('form' => NULL),
        ),
      );
    }

    function yourtheme_theme() {
      $items = array();
      $items['user_login'] = array(
        'render element' => 'form',
        'path' => drupal_get_path('theme', 'yourtheme') . '/templates',
        'template' => 'user-login',
        'preprocess functions' => array(
           'yourtheme_preprocess_user_login'
        ),
      );
      return $items;
    }

    function yourtheme_preprocess_user_login(&$vars) {
      $vars['intro_text'] = t('This is my awesome login form');
    }

在主题的“templates”文件夹中创建一个名为user-login.tpl.php的文件。

添加此代码并将“yourtheme”更改为您的主题名称。

 <?php print drupal_render_children($form) ?>

清除缓存。

Source(您可以在哪里找到有关如何为user-register-form,user-password-form和Drupal 6执行此操作的详细信息) https://drupal.org/node/350634

答案 4 :(得分:0)

另一种方法是使用&#34; Panel&#34;创建custon注册页面:

  1. 安装并启用Panel Module
  2. 创建新页面&#34;注册页面&#34;并设计布局
  3. 向您的地区添加内容。对于您的情况,&#34;注册块&#34;或&#34;登录栏&#34;
相关问题