2011-04-04 153 views
0

在我的网站www.rchealth.co.uk中,我想添加搜索。如何在Drupal中编辑搜索区域

我已启用搜索模块,并且搜索块位于标题中,现在我想自定义搜索外观并使其看起来更好。

我已经搜索并发现了一些像http://systemseed.com/blog/how-customise-search-box-drupal-6http://drupal.org/node/154137

方法我遵循的步骤,但我仍然无法编辑模板。我的Drupal的版本是6.17

我粘贴在此的template.php代码

function accordlaw_preprocess_search_block_form(&$vars, $hook) { 
    // Modify elements of the search form 
    unset($vars['form']['search_block_form']['#title']); 

    // Set a default value for the search box 
    $vars['form']['search_block_form']['#value'] = t('Search RC Health'); 

    // Add a custom class to the search box 
    // Set yourtheme.css > #search-block-form .form-text { color: #888888; } 
    $vars['form']['search_block_form']['#attributes'] = array(
    'onblur' => "if (this.value == '') {this.value = '".$vars['form']['search_block_form']['#value']."';} this.style.color = '#000000';", 
    'onfocus' => "if (this.value == '".$vars['form']['search_block_form']['#value']."') {this.value = '';} this.style.color = '#000000';" 
); 

    // Modify elements of the submit button 
    unset($vars['form']['submit']); 

    // Change text on the submit button 
    //$vars['form']['submit']['#value'] = t('Go!'); 

    // Change submit button into image button - NOTE: '#src' leading '/' automatically added 
    $vars['form']['submit']['image_button'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/images/search-button.png'); 

    // Rebuild the rendered version (search form only, rest remains unchanged) 
    unset($vars['form']['search_block_form']['#printed']); 
    $vars['search']['search_block_form'] = drupal_render($vars['form']['search_block_form']); 

    // Rebuild the rendered version (submit button, rest remains unchanged) 
    unset($vars['form']['submit']['#printed']); 
    $vars['search']['submit'] = drupal_render($vars['form']['submit']); 

    // Collect all form elements to print entire form 
    $vars['search_form'] = implode($vars['search']); 
} 
+0

你是什么意思时,你说“无法编辑模板”做。修改没有显示?你真的在文件中添加了什么,发布你的代码。 – Haza 2011-04-04 14:55:28

+0

你想要什么用搜索框呢? – LostLin 2011-04-04 15:15:34

+0

我想删除文本搜索:想要让按钮的图像降低输入字段宽度的地方四处搜寻区域的背景图像。此外,我刚才注意到,当我与联系其显示在所有页面搜索loged的,但如果我有一些其他的浏览器浏览网站,而不登录搜索没有出现。 – nasir 2011-04-04 15:27:10

回答

2

你说搜索块是在头...你的意思是主题搜索?您使用的代码是区块搜索表单。

,你看不到的时候不以管理员身份登录搜索表单的最可能的原因是你没有给正确的权限使用“搜索”以匿名的(也可能是经过身份验证的)用户。

要更改主题的外观/感觉/功能在主题的标题中搜索,您始终可以使用模板文件(search-theme-form.tpl.php)。

复制从搜索主题form.tpl.php“/模块/搜索”,并贴到您的主题目录。进行所需的任何编辑,然后通过“www.example.com/admin/settings/performance”清除缓存。使用search-theme-form.tpl.php

的更多信息:
search-theme-form.tpl.php (Drupal Docs)
How to Theme the Search Form for Drupal 6

相关问题