简体   繁体   English

如何为drupal中每个用户角色的profile2登录/注册页面创建自定义模板文件

[英]How to create custom template file for login/register pages of profile2 each user role in drupal

I'm making a job vacancies site and it has two roles, user and employer. 我正在创建一个职位空缺网站,它有两个角色,用户和雇主。 I used profile2 and have unique registration path for both roles. 我使用了profile2并且两个角色都有唯一的注册路径。 I already make the custom login/register page for user and it goes well. 我已经为用户创建了自定义login/register页面,并且运行良好。 I want to make custom login/register page for employer too. 我也想为雇主创建自定义login/register页面。 I already tried making page--employer.tpl.php and it didn't work. 我已经尝试过制作page--employer.tpl.php ,但它没有用。

Here is codes in page--user.tpl.php for user login/register : 这是page--user.tpl.php用于用户login/register

<?php if(!user_is_logged_in()): ?>
<div class="vertical-align user-page-form">
<div class="vertical-align-center">
<div class="horizontal-align-middle">
  <div id="up-logo">
    <a href="<?php print $front_page; ?>" rel="home">
      <img src="<?php print $logo; ?>" />
    </a>
  </div>

  <?php if ($messages): ?>
    <?php print $messages; ?>
  <?php endif; ?>

  <?php print render($page['content']); ?>

  <div class="login-footer">
  <?php if($_GET['q'] == 'user' || $_GET['q'] == 'user/login'): ?>
    <?php print l('Create new account', 'user/register', array('attributes' => array('class' => 'left'))); ?>
    <?php print l('Reset your password', 'user/password', array('attributes' => array('class' => 'right'))); ?>
  <?php elseif($_GET['q'] == 'user/register'): ?>
    <?php print l('Sign in', 'user/login', array('attributes' => array('class' => 'left'))); ?>
    <?php print l('Reset your password', 'user/password', array('attributes' => array('class' => 'right'))); ?>
  <?php elseif($_GET['q'] == 'user/password'): ?>
    <?php print l('Create new account', 'user/register', array('attributes' => array('class' => 'left'))); ?>
    <?php print l('Sign in', 'user/login', array('attributes' => array('class' => 'right'))); ?>
  <?php endif; ?>
  </div>
  </div>
  </div>
  </div>
  <?php else: ?>

  <div class="page">
  <?php if ($tabs): ?>
  <div class="tabs"><?php print render($tabs); ?></div>
  <?php endif; ?>

  <?php print render($page['content']); ?>
  </div>
  <?php endif; ?>

You can implement (in your template.php) template_preprocess_page($variables) and add your own template file name suggestion via the $vars['theme_hook_suggestions'] array. 您可以实现(在您的template.php中) template_preprocess_page($variables)并通过$vars['theme_hook_suggestions']数组添加自己的模板文件名建议。

You can check the current path (in an if statement to know when to add the suggestion) with current_path() or drupal_get_path_alias() 您可以使用current_path()drupal_get_path_alias()检查当前路径(在if语句中了解何时添加建议)。

Take a look at the API for template_preprocess_page . 看一下template_preprocess_page的API。

Also take a look at this stack question 还看看这个堆栈问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM