2013-07-29 156 views
0

我已經創建了一個名爲「test」的自定義主題,並且我試圖顯示搜索結果。自定義Drupal搜索結果頁面

我在template.php中添加了函數test_preprocess_search_results()(從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中文件的檢索結果顯示?這樣做的page.tpl <?php print render($page['search_result']); ?> .php div?我不確定默認主題怎麼知道在哪裏顯示搜索結果?誰能幫忙謝謝

PS:我做了什麼後,並刷新緩存,沒有出現

回答

1

的搜索結果,你應該使用搜索results.tpl.php(所有結果列表)和搜索result.tpl .php(單個列表項目)模板。將它們從ROOT/modules/search文件夾複製到主題文件夾中,並根據需要覆蓋它們。