在我的网站www.rchealth.co.uk中,我想添加搜索。如何在Drupal中编辑搜索区域
我已启用搜索模块,并且搜索块位于标题中,现在我想自定义搜索外观并使其看起来更好。
我已经搜索并发现了一些像http://systemseed.com/blog/how-customise-search-box-drupal-6和http://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']);
}
你是什么意思时,你说“无法编辑模板”做。修改没有显示?你真的在文件中添加了什么,发布你的代码。 – Haza 2011-04-04 14:55:28
你想要什么用搜索框呢? – LostLin 2011-04-04 15:15:34
我想删除文本搜索:想要让按钮的图像降低输入字段宽度的地方四处搜寻区域的背景图像。此外,我刚才注意到,当我与联系其显示在所有页面搜索loged的,但如果我有一些其他的浏览器浏览网站,而不登录搜索没有出现。 – nasir 2011-04-04 15:27:10