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

Ask A Question

Stats

  • Questions 529k
  • Answers 529k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As you said you can write a JavaScript code to… May 16, 2026 at 11:15 pm
  • Editorial Team
    Editorial Team added an answer You should look up the ICommand interface and implement it… May 16, 2026 at 11:15 pm
  • Editorial Team
    Editorial Team added an answer A TCP connection is defined by a unique set of… May 16, 2026 at 11:15 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm looking at this code and have been through the docs but still don't
I've been going through FB docs but I think I am totally lost now.
I have been struggling with this all day and have tried going through the
So i have a site that I am working on that has been touched
I've been mystified by the R quantile function all day. I have an intuitive
I have a spring project that works beautifully when it's located at the web
I have been reading about creating an RPM for Python 2.6.4. In this page:
after going through some basic tutorials on the app engine and the webapp framework,
Ive been trying to sort out output using AWK, and have been pretty successful
I might be a little late on this but I was going through how

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.