dongnan1899 2013-03-18 16:27
浏览 29
已采纳

在Drupal 7中创建自定义页面时出错

(Using Adaptive Theme) I want a new and custom user login page. So, put this code in my 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. And created user-login.tpl.php files and put this code:

<?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.

Where the error am I doing? How can I solve this problem?

  • 写回答

1条回答 默认 最新

  • dozabt4329 2013-03-19 04:24
    关注

    Try putting this in template.php, change mythemename to theme name, and flush the cache.

    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:

    <?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) ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 win2012 iscsi ipsec
  • ¥15 封装的 matplotlib animation 不显示图像
  • ¥15 python摄像头画面无法显示
  • ¥15 关于#3d#的问题:d标定算法(语言-python)
  • ¥15 cve,cnnvd漏洞扫描工具推荐
  • ¥15 图像超分real-esrgan网络自己训练模型遇到问题
  • ¥15 如何构建全国统一的物流管理平台?
  • ¥100 ijkplayer使用AndroidStudio/CMake编译,如何支持 rtsp 直播流?
  • ¥15 用js遍历数据并对非空元素添加css样式
  • ¥15 使用autodl云训练,希望有直接运行的代码(关键词-数据集)