Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1000495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:31:20+00:00 2026-05-16T07:31:20+00:00

I have been going through the docs and source code looking for something without

  • 0

I have been going through the docs and source code looking for something without luck.

Is there a Drupal 6 hook that gets called after hook_search(), but before the $results gets handed off to the template system?

I need to do a fairly custom pruning and reordering of results that get returned. I could just reimplement hook_search(), but this seems like overkill.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:31:20+00:00Added an answer on May 16, 2026 at 7:31 am

    There isn’t; search_view() (which displays the results) calls search_data(), which invokes hook_search() then immediately themes the results. Re-implementing hook_search() is probably the most straightforward route.

    With that said, you could instead implement hook_menu_alter() and have the search page call your custom function instead of calling search_view() (and subsequently calling search_data()). Something like:

    function test_menu_alter(&$items) {
      $items['search']['page callback'] = 'test_search_view';
    
      foreach (module_implements('search') as $name) {
        $items['search/' . $name . '/%menu_tail']['page callback'] = 'test_search_view';
      }
    }
    
    // Note: identical to search_view except for --- CHANGED ---
    function test_search_view($type = 'node') {
      // Search form submits with POST but redirects to GET. This way we can keep
      // the search query URL clean as a whistle:
      // search/type/keyword+keyword
      if (!isset($_POST['form_id'])) {
        if ($type == '') {
          // Note: search/node can not be a default tab because it would take on the
          // path of its parent (search). It would prevent remembering keywords when
          // switching tabs. This is why we drupal_goto to it from the parent instead.
          drupal_goto('search/node');
        }
    
        $keys = search_get_keys();
        // Only perform search if there is non-whitespace search term:
        $results = '';
        if (trim($keys)) {
          // Log the search keys:
          watchdog('search', '%keys (@type).', array('%keys' => $keys, '@type' => module_invoke($type, 'search', 'name')), WATCHDOG_NOTICE, l(t('results'), 'search/'. $type .'/'. $keys));
    
          // Collect the search results:
          // --- CHANGED --- 
          // $results = search_data($keys, $type);
          // Instead of using search_data, use our own function
          $results = test_search_data($keys, $type);
          // --- END CHANGED ---
    
          if ($results) {
            $results = theme('box', t('Search results'), $results);
          }
          else {
            $results = theme('box', t('Your search yielded no results'), search_help('search#noresults', drupal_help_arg()));
          }
        }
    
        // Construct the search form.
        $output = drupal_get_form('search_form', NULL, $keys, $type);
        $output .= $results;
    
        return $output;
      }
    
      return drupal_get_form('search_form', NULL, empty($keys) ? '' : $keys, $type);
    }
    
    // Note: identical to search_data() except for --- CHANGED ---
    function test_search_data($keys = NULL, $type = 'node') {
    
      if (isset($keys)) {
        if (module_hook($type, 'search')) {
          $results = module_invoke($type, 'search', 'search', $keys);
          if (isset($results) && is_array($results) && count($results)) {
            // --- CHANGED ---
            // This dsm() is called immediately after hook_search() but before
            // the results get themed. Put your code here.
            dsm($results);
            // --- END CHANGED ---
    
            if (module_hook($type, 'search_page')) {
              return module_invoke($type, 'search_page', $results);
            }
            else {
              return theme('search_results', $results, $type);
            }
          }
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been going through some code and came across a statement that somehow
I'm looking at this code and have been through the docs but still don't
i have been going through the source code of an application which i downloaded
I have been going through the core jQuery code and had a few why
I have been recently going through my database code trying to improve on my
I have been going up and down through all kinds of reference docs and
have been going through here and google looking for a spellcheck solution. I see
I need to learn couchbd and have been going through tutorials on views. I
Recently, I have been going through search trees and I encountered red-black trees, the
I am complete newbie in mod_rewrite , and I have been going through some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.