2011-08-20 72 views
0

我發現了很多有關如何在D6上執行此操作的教程,但是,似乎我發現的示例代碼在歐米茄子主題上並不完美。Drupal 6中的主題用戶註冊頁面,帶有Omega子主題

Here's代碼從來就發現它很適合我最好的(via Trellon):

內template.tpl.php:

<?php 
function themename_theme($existing, $type, $theme, $path) { 
    return array(
    ... 
    // tell Drupal what template to use for the user register form 
    'user_register' => array(
     'arguments' => array('form' => NULL), 
     'template' => 'user-register', // this is the name of the template 
    ), 
    ... 
); 
} 
?> 

而且here's用戶register.tpl。 PHP的形式:

<div id="registration_form"> 
    <div class="field"> 
    <?php 
     print drupal_render($form['account']['name']); // prints the username field 
    ?> 
    </div> 
    <div class="field"> 
    <?php 
     print drupal_render($form['account']['pass']); // print the password field 
    ?> 
    </div> 
    <div class="field"> 
    <?php 
     print drupal_render($form['submit']); // print the submit button 
     ?> 
    </div> 
    </div> 
</div> 

的事情是,我template.tpl.php文件裏從來就已經宣佈mytheme_theme,所以我不知道如何添加新的代碼。

裏面我的歐米茄次主題文件夾:

/** 
* Implementation of HOOK_theme(). 
*/ 
function lcph_theme(&$existing, $type, $theme, $path) { 
    $hooks = omega_theme($existing, $type, $theme, $path); 
    // Add your theme hooks like this: 
    /* 
    $hooks['hook_name_here'] = array(// Details go here); 
    */ 
    // @TODO: Needs detailed comments. Patches welcome! 
    return $hooks; 

} 

事實上,如果我只是複製/粘貼我的模板文件中的代碼,這是從來就得到了錯誤:

Fatal error: Cannot redeclare lcph_theme() (previously declared in /sites/all/themes/lcph/template.php:22) in /sites/all/themes/lcph/template.php on line 125 

如何我可以在我的omega subtheme模板中添加示例代碼嗎? 感謝您的指導和幫助!

Rosamunda

回答

1

不添加任何東西的template.php文件,除非你在你的template.php文件中搜索omega_theme()函數,如果你發現了它,然後修改它......如果你沒有找到它,然後創建你自己的一個......我不完全理解你,但也許下面的步驟可能會幫助你

1-搜索你的template.php文件 *如果你沒有找到它然後創建你自己的一個在你的主題文件夾中 2-在你的template.php文件中搜索urthemename_theme()函數 *如果你發現它,那麼你可以修改它......如果你不能,你可以創建你自己的函數 爲以下

function omega_theme($existing, $type, $theme, $path) { 
    return array(
    'user_register' => array(
     'arguments' => array('form' => NULL), 
     'template' => 'user-register', // this is the name of the template 
    ), 
); 
} 

3-尋求在烏拉圭回合的主題文件user_register.tpl.php文件...如果u沒有找到它然後創建 自己一個,並把下面的代碼裏面

<div id="registration_form"> 
    <div class="field"> 
    <?php 
     print drupal_render($form['account']['name']); // prints the username field 
    ?> 
    </div> 
    <div class="field"> 
    <?php 
     print drupal_render($form['account']['pass']); // print the password field 
    ?> 
    </div> 
    <div class="field"> 
    <?php 
     print drupal_render($form['submit']); // print the submit button 
     ?> 
    </div> 
    </div> 
</div> 

我不知道你的template.tpl.php文件的意思......我想你指的template.php 我希望幫助你