0

我创建了一个名为“test”的自定义主题,并尝试显示搜索结果。

我将函数 test_preprocess_search_results() 添加到 template.php (从 drupal 页面“function template_preprocess_search_results”复制代码,然后将 search-result.tpl.php 从搜索模块复制到“test”的模板文件夹。

function test_preprocess_search_results(&$variables) { $variables['search_results'] = ''; if (!empty($variables['module'])) { $variables['module'] = check_plain($variables['module']); } foreach ($variables['results'] as $result) { $variables['search_results'] .= theme('search_result', array('result' => $result, 'module' => $variables['module'])); } $variables['pager'] = theme('pager', array('tags' => NULL)); $variables['theme_hook_suggestions'][] = 'search_results__' . $variables['module']; }

我是 drupal 的新手,我关心的是如何使搜索结果显示在我的 page.tpl.php 文件中声明的某些 div 中?<?php print render($page['search_result']); ?>在 page.tpl.php div 中做类似的事情?我不确定默认主题如何知道在哪里显示搜索结果?谁能帮忙谢谢

ps:在我做完之后,刷新缓存,什么都没有出现

4

1 回答 1

1

For search results you should use the search-results.tpl.php (all results list) and search-result.tpl.php (single list item) templates. Copy them from ROOT/modules/search folder into your theme folder and override them as you prefer.

于 2013-07-30T14:51:42.637 回答