[英]Error when creating a custom page in Drupal 7
(Using Adaptive Theme) I want a new and custom user login page. (使用自适应主题)我想要一个新的自定义用户登录页面。 So, put this code in my template.php:
因此,将此代码放在我的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;
}
Changed mythemename to my custom theme name. 将mythemename更改为我的自定义主题名称。 And created user-login.tpl.php files and put this code:
并创建了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']);
?>
Lastly, cleared my site cache. 最后,清除了我的网站缓存。 But when i click mysite.com/user login page not changed.
但是,当我单击mysite.com/user登录页面时,未更改。
Where the error am I doing? 我在哪里出错? How can I solve this problem?
我怎么解决这个问题?
Try putting this in template.php, change mythemename to theme name, and flush the cache. 尝试将其放在template.php中,将mythemename更改为主题名称,然后刷新缓存。
function mythemename_theme($existing, $type, $theme, $path){
$hooks['user_login']=array(
'render element'=>'form',
'template'=>'templates/user-login',
);
return $hooks;
}
Then in templates/user-login.tpl.php insert: 然后在template / 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']);
?>
or 要么
<?php print drupal_render_children($form) ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.