Hi all,

I'm trying to find a way so that results of the search module will produce a cleaner url.

instead of : search/node/...
I'd like it to be: search/result/... or just search/...

I just find having "node" kinda ugly. I know that shouldn't be a criteria but working hard to make all my urls clean and pretty. So why not this right?

I have Drupal 6x installed
+: clean url, path redirect, global redirect, & pathauto

Possible? Or is there something better I should be thinking about?

Thanks.

Comments

pokadan’s picture

/**
 * Implement hook_alter to remove the search submit handlers handlers from search_form and search_theme_form and also the action path
 */
function ydo_form_alter(&$form, &$form_state, $form_id){
	if($form_id=="search_form" || $form_id=="search_theme_form"){
		
		unset( $form['#submit']);
		$form['#submit'][] = 'ydo_search_submit_handler';
		if($form_id=="search_form"){
			$search_string = $form_state['post']['keys'];
		}
		if($form_id=="search_theme_form"){
			$search_string = $form_state['post']['search_theme_form'];
		}
		$form_state['#ydo_param1'] = $search_string;
		$form['#action'] = '/search/'.$search_string;
		
	}
}
function ydo_search_submit_handler($form, &$form_state){
	//dpr($form);
	//exit;		
	$search_string = $form_state['#ydo_param1'];
	$form_state['redirect']= 'search/'.$search_string;
}

I used this to bring paths like /search/apachesolr_search/ to just /search/