2014-01-16 26 views
0

我想重寫page.tpl.php來創建自定義登錄頁面。 類實際登錄的身體標記的是:覆蓋page.tpl.php爲Drupal 7中的登錄頁面

<body class="html front not-logged-in one-sidebar sidebar-first page-customerror page-customerror- page-customerror-403 i18n-en"> 

怎麼可能是新的文件覆蓋page.tpl.php中的名字嗎?

我試過page--not-logged-in.tpl.php,page-not-logged-in.tplpage-front-not-logged-in.tpl但似乎沒有任何工作。

我也刷新緩存每次我改變文件的名稱,但沒有發生。

回答

0

您可以定義一個預處理功能

1)添加在您的template.php

function yourcustomtheme_preprocess_page($vars) { 
    global $user; 
    if ($user->uid ==0)) { 
     $vars['template_files'][] = 'page-not-logged'; 
    } 
} 

2)現在,你可以使用page-not-logged.tpl.php

其他方式,你可以使用所有相同的模板用戶

編輯您的page.tpl.php並添加

<?php 
global $user; 
if($user->uid ==0){ 
    //Your code for anon users 
} 
else { 
    //Copy the original page.tpl here 
} 
?> 
0

在你的主題template.php文件

function [YOUR_THEME]_preprocess_page(&$vars) { 
    global $user; 

    if($user->uid < 1 && arg(0) == "user") { 
     $vars['theme_hook_suggestion'] = 'page-not-logged-in'; 
    } 
}