How to use a tpl.php file for a theme function I am using LoginToboggan which provides a theme function. You can use this theme function in a template.php file to control the mark up.

However, the code becomes quite unwieldy in template.php. Is there any way to modify the function so it can use a tpl.php file?



More info

This is the function LoginToboggan provides:

function theme_lt_unified_login_page($variables) {

  $login_form = $variables['login_form'];
  $register_form = $variables['register_form'];
  $active_form = $variables['active_form'];
  $output = '';

  $output .= '&lt;div class="toboggan-unified ' . $active_form . '"&gt;';

  // Create the initial message and links that people can click on.
  $output .= '&lt;div id="login-message"&gt;' . t('You are not logged in.') . '&lt;/div&gt;';
  $output .= '&lt;div id="login-links"&gt;';
  $output .= l(t('I have an account'), 'user/login', array('attributes' =&gt; array('class' =&gt; array('login-link'), 'id' =&gt; 'login-link')));
  $output .= ' ';
  $output .= l(t('I want to create an account'), 'user/register', array('attributes' =&gt; array('class' =&gt; array('login-link'), 'id' =&gt; 'register-link')));

  $output .= '&lt;/div&gt;';

  // Add the login and registration forms in.
  $output .= '&lt;div id="login-form"&gt;' . $login_form . '&lt;/div&gt;';
  $output .= '&lt;div id="register-form"&gt;' . $register_form . '&lt;/div&gt;';

  $output .= '&lt;/div&gt;';

  return $output;
}
Create a template file lt-unified-login.tpl.php in your theme directory and put this function inside template.php to override theme_lt_unified_login_page &amp; return the HTML output of lt-unified-login.tpl.php.

function YOURTHEME_lt_unified_login_page($variables) {
  $template = drupal_get_path('theme', 'YOURTHEME').'/lt-unified-login.tpl.php';
  return theme_render_template($template, $variables);
}