(使用自适应主题)我想要一个新的自定义用户登录页面。所以,把这段代码放在我的template.php中:
function mythemename_theme() {
$items = array();
// create custom user-login.tpl.php
$items['user_login'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'mythemename') . '/templates',
'template' => 'user-login',
'preprocess functions' => array(
'mythemename_preprocess_user_login'
),
);
return $items;
}
将mythemename更改为我的自定义主题名称。并创建了user-login.tpl.php文件并输入以下代码:
<?php
print drupal_render($form['name']);
print drupal_render($form['pass']);
print drupal_render($form['form_build_id']);
print drupal_render($form['form_id']);
print drupal_render($form['actions']);
?>
最后,清除了我的网站缓存。但是当我点击mysite.com/user登录页面时没有改变。
我在做错误的地方?我该如何解决这个问题?
答案 0 :(得分:1)
尝试将其放入template.php,将 mythemename 更改为主题名称,然后刷新缓存。
function mythemename_theme($existing, $type, $theme, $path){
$hooks['user_login']=array(
'render element'=>'form',
'template'=>'templates/user-login',
);
return $hooks;
}
然后在templates / user-login.tpl.php中插入:
<?php
print render($form['name']);
print render($form['pass']);
print render($form['form_build_id']);
print render($form['form_id']);
print render($form['actions']);
?>
或
<?php print drupal_render_children($form) ?>