2010-01-12 107 views
1

我想顯示自定義頁面作爲我的搜索結果頁面通過重複使用內置的搜索模塊的主題功能和預處理器相同。Drupal主題()的問題

有了一個空的Drupal緩存本精美的作品。我簡單地打電話

theme('search_results', $results, 'node'); 

帶正確popuated結果數組,我回來格式化標記。 太好了。

但是,當緩存不清晰時,搜索模塊不可用,因此theme()調用無處可用,並返回空字符串。

我試過drupal_load('module','search'),它使模塊文件可用,但不初始化它的hook_theme。

回答

0

具有以下固定它:

function_exists('search_theme') or drupal_load('module','search'); 
function_exists('template_preprocess_search_results') or module_load_include('inc','search','search.pages'); 

我不喜歡,雖然它。

+0

都drupal_load和module_load_include可以運行超過一次,所以你不需要function_exists更多。還要確保你在你的模塊中用搜索定義了一個依賴項。 – 2010-01-13 14:24:26