DRUPAL6 module Template Rewrite

Source: Internet
Author: User
Tags php file php and php print drupal

According to Drupal official website http://drupal.org/node/350634 article.

The custom user login, registration and password reset pages are simple, with the following steps:

Step one: In the folder where the theme is located, edit the template.php file, look for a function named Yourtheme_theme (Yourtheme refers to the name of the theme you use), and make the following modifications:

?

1 2 3 4 5 6 7 8 9 Ten each of the above /** * Registers overrides for VA rious functions. * * In this case, overrides three user functions */function Yourtheme_theme () {   return array (  & nbsp;  ' user_login ' = = Array (       ' template ' = ' user-login ',         ' arguments ' = = Array (' form ' = NULL),     ),    & nbsp ' User_register ' = = Array (       ' template ' = ' user-register ',         ' arguments ' = = Array (' form ' = NULL),     ),    & nbsp ' User_pass ' = Array (       ' template ' = ' user-pass ',     & nbsp;  ' arguments ' = = Array (' form ' = NULL),     ),   ); }

Attention:

Replace ' Yourtheme ' with your theme name

Three pages can use the same template, three templates are used in this column (User-login, User-register, and User-pass)

The name of the template uses dashes, not underscores

Attention is user-pass, not user-password.

Step Two:

Next, write three preprocessing functions, as follows:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 Function Yourtheme_preprocess_user_login (& $variables) {$variables [' intro_text '] = t (' This is my awesome Logi    n Form '); $variables [' rendered '] = Drupal_render ($variables [' form ']); } function Yourtheme_preprocess_user_register (& $variables) {$variables [' intro_text '] = t (' This is my sup    Er awesome reg form '); $variables [' rendered '] = Drupal_render ($variables [' form ']); } function Yourtheme_preprocess_user_pass (& $variables) {$variables [' intro_text '] = t (' This is my super A    Wesome insane Password form '); $variables [' rendered '] = Drupal_render ($variables [' form ']); }

Attention:

Replace ' Yourtheme ' with your theme name

The text content of the variable $variables[' Intro_text ' in the array $variables is passed through $intro_text to the page

Step three: Create template files user-login.tpl.php and user-register.tpl.php to correspond to the ' template ' defined above and add code to this file:

?

1 2 3) 4 5 <p><?php print $intro _text,?></p> <div class = "My-form-wrapper" > <?php print $render Ed;?> </div>

Step four: Save the file and empty the cache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.