How to override theme function in Drupal 6?

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.


In your template.php, use hook_theme() API function to override the output of the theme.
As an example, we use the code below in template.php:


<?php
/**
*
* In this case, we are overriding user_login functions
*/
function yourtheme_theme() {
  return array(
    
'user_login' => array(
      
'template' => 'user-login',
      
'arguments' => array('form' => NULL),
    ),
  );
}
?>

Now, Drupal would expect to see user-login.tpl.php in your theme folder (which is yourtheme). You can do print_r($form) and control the output of your form that is printed on the login page.

                                     

Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.