tags:

views:

604

answers:

1

Hi,

I built a simple block module with a select box (where a user can select a certain type of user or project or og group) and can fill in a search term.

At submit it queries the nodes that have theses tags.

The results, links to user profiles or nodes, have to be printed on the page.

I dont know how to print the results.

I want to go to another page, and show the results there... But how can I do that?

<?php
// $Id$

/*
 * @file
 * Searches on Project, Person, Freelancer or Group. Search will be done on taxonomy.
 */

define('GENERAL_TAGS_VID', 25);

/**
 * Implementation of hook_menu().
 */
function vm_search_menu() {
  $items['zoek'] = array(
    'title' =>  t('Zoek'),
    'page callback' => 'zoek_view',
    'access arguments' => array('search content'),
    'type' => MENU_SUGGESTED_ITEM,
  );
  return $items;
}

/**
  * Define the form.
  */
function vm_search_general_search_form() {
    $search_on  = array(
     'project' => 'Zoek project',
     'freelancer' => 'Zoek freelancer',
     'persoon' => 'Zoek persoon',
     'groep' => 'Zoek groep',  
    );

    $form['search_on'] = array(
     '#type' => 'select',
    '#options' => $search_on,
    );
    $form['search_term'] = 
     array('#type' => 'textfield',
          '#autocomplete_path' => 'taxonomy/autocomplete/'. GENERAL_TAGS_VID,
          '#maxlength' => 1024,
    );
   $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Zoek'),
   );
   return $form;
}


function vm_search_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {
    case 'list':
      $blocks[0]['info'] = t('General Search');
      return $blocks;
    case 'view':
      $block['subject'] = t('Zoek');
      $block['content'] = drupal_get_form('vm_search_general_search_form');
      return $block;
    }
}

function vm_search_general_search_form_submit($form, &$form_state) {
    switch ($form_state['values']['search_on']) {
     case 'project':
     case 'groep': 
      $nodes = search_nodes($form_state);
      break;
     case 'freelancer':
     case 'persoon':
      $users = search_users($form_state);
    }
  dpm($form_state);
}
+1  A: 

You can probably handle this a number of ways but 2 that you might consider:
1. (The way default search handles it) Add search params to the url so that they can be extracted and viewed on the appropriate page. Don't actually query the results until you've sent them to the page you've defined in your menu hook.
2. Change the post location of your form and tell your form not to redirect. By default, your forms will post back to the same page and redirect at the end of the post. By using the following you should be able to affect that behavior:

  $form['#action'] = url('zoek');
  $form['#redirect'] = FALSE;
William OConnor - csevb10