zoukankan      html  css  js  c++  java
  • [转]Drupal6模块模板重写

    根据drupal官方网站http://drupal.org/node/350634的文章。

    自定义用户登录,注册和密码重置页面都很简单,具体步骤如下:

    步骤一:在主题所在的文件夹,编辑template.php文件,寻找名为yourtheme_theme(yourtheme是指你使用的主题的名字)的函数,并进行如下修改:

        /**
        * Registers overrides for various functions.
        *
        * In this case, overrides three user functions
        */
        function yourtheme_theme() {
          return array(
            'user_login' => array(
              'template' => 'user-login',
              'arguments' => array('form' => NULL),
            ),
            'user_register' => array(
              'template' => 'user-register',
              'arguments' => array('form' => NULL),
            ),
            'user_pass' => array(
              'template' => 'user-pass',
              'arguments' => array('form' => NULL),
            ),
          );
        }
    

    注意:

    用你的主题名称替换‘yourtheme'

    三个页面可以使用相同的模板,在本列中使用了三种模板(user-login、user-register和user-pass)

    模板的名称中使用短划线,不是下划线

    注意是user-pass而不是user-password

    步骤二:

    接下来,写三个预处理函数,如下:

        function yourtheme_preprocess_user_login(&$variables) {
          $variables['intro_text'] = t('This is my awesome login form');
          $variables['rendered'] = drupal_render($variables['form']);
        }
          
        function yourtheme_preprocess_user_register(&$variables) {
          $variables['intro_text'] = t('This is my super awesome reg form');
          $variables['rendered'] = drupal_render($variables['form']);
        }
          
        function yourtheme_preprocess_user_pass(&$variables) {
          $variables['intro_text'] = t('This is my super awesome insane password form');
          $variables['rendered'] = drupal_render($variables['form']);
        }
    

    注意:

    用你的主题名称替换'yourtheme'

    数组 $variables中变量$variables['intro_text']的文字内容将通过$intro_text传递到页面

    步骤三:创建模板文件user-login.tpl.php和user-register.tpl.php来对应上面定义的'template',并在这个文件中添加一下代码:

        <p><?php print $intro_text; ?></p>
          
        <div class="my-form-wrapper">
          <?php print $rendered; ?>
        </div>
    

    步骤四:保存文件,并清空缓存

  • 相关阅读:
    类的特殊获取方式——《Thinking in Java》随笔008
    方法排序规范——《Thinking in Java》随笔007
    权限修饰符(访问指示符)——《Thinking in Java》随笔006
    史上最强,万能类型:Object——《Thinking in Java》随笔005
    七天C#小结
    编译原理10 消除左递归
    编译原理9 DFA最小化,语法分析初步
    编译原理8 非确定的自动机NFA确定化为DFA
    编译原理7 正规式、正规文法与自动机
    编译原理6 正规文法与正规式
  • 原文地址:https://www.cnblogs.com/catcat811/p/1942836.html
Copyright © 2011-2022 走看看