首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Drupal中搜索框的主题存在问题

Drupal中搜索框的主题存在问题
EN

Stack Overflow用户
提问于 2011-05-20 15:46:51
回答 1查看 1.1K关注 0票数 0

我不是世界上最有经验的Drupal,我正在做一个噩梦,试图定制搜索框。我正在使用Drupal帮助站点的示例,它根本不起作用。

我已经将搜索主题-form.tpl.php从搜索模块复制到我的主题中,并复制了示例代码,在预处理函数之外的代码中的任何HTML都显示得很好,但据我所知,预处理函数要么没有被调用,要么只是没有影响我的搜索框。

我几乎可以肯定,对于Drupal是如何工作的,我忽略了一些基本的基本信息,但我根本找不到任何信息。

下面是代码:

代码语言:javascript
复制
 <?php 

function danland_preprocess_search_theme_form(&$vars, $hook) {
      // Remove the "Search this site" label from the form.


  $vars['form']['search_theme_form']['#title'] = t('');

  // Set a default value for text inside the search box field.
  $vars['form']['search_theme_form']['#value'] = t('Search this Site');

  // Add a custom class and placeholder text to the search box.
  $vars['form']['search_theme_form']['#attributes'] = array('class' => 'NormalTextBox txtSearch', 'onblur' => "if (this.value == '') {this.value = '".$vars['form']['search_theme_form']['#value']."';} ;", 'onfocus' => "if (this.value == '".$vars['form']['search_theme_form']['#value']."') {this.value = '';} ;" );


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

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

  $vars['form']['submit']['#type'] = 'image_button';
  $vars['form']['submit']['#src'] = path_to_theme() . '/images/search.jpg';

  // 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 make it easier to print the whole form.
  $vars['search_form'] = implode($vars['search']);
}

?>


<div id="search" class="container-inline">
  <?php print $search_form; print $search_theme_form; ?>
</div>
EN

回答 1

Stack Overflow用户

发布于 2011-05-20 16:53:26

将预处理函数放在主题目录中的template.php中,然后在“admin/ function /performance”处清除缓存

下面是一些关于模板/预处理函数主题化的有用链接:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6074379

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档