2013-03-18 66 views
0

(使用自適應主題)我想要一個新的自定義用戶登錄頁面。所以,把這個代碼放在我的template.php中:在Drupal 7中創建自定義頁面時出錯

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更改爲我的自定義主題名稱。而創建的用戶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

使用用戶名 - login.tpl.php而不是用戶登錄。 tpl.php bcoz在drupal 7中使用double - 而不是1 – 2013-03-19 05:47:52

+0

請不要交叉提問。選擇一個最匹配的網站。 http://drupal.stackexchange.com/questions/65475/error-when-creating-a-custom-page-in-d7 – 2013-04-23 18:45:25

回答

1

試着把它放在template.php中,將mythemename更改爲主題名稱,然後刷新緩存。

function mythemename_theme($existing, $type, $theme, $path){ 
    $hooks['user_login']=array(
    'render element'=>'form', 
    'template'=>'templates/user-login', 
    ); 
    return $hooks; 
} 

然後在模板/用戶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) ?>