Display search results in a new page

rmahon - April 26, 2007 - 15:18
Project:Google Ajax Search Module
Version:5.x-1.0
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Has anyone figured out how to display these results in a separate page instead of on the side bar?

Thanks
Ron

#1

waynedrupal - July 27, 2007 - 01:39

No. I am thinking that the demonstration page has this not in a block, so I was hoing that this could be done also. Any response to this question?

#2

waynedrupal - July 27, 2007 - 02:06

In documentation it says: A googleajaxsearch macro can be created on the googleajaxsearch/macro page and the text can then be
copied and pasted into any node where the googleajaxsearch filter is enabled.

Does anyone know what this means? I tried to add the macro example

[googleajaxsearch|target=blank|state=closed|mode=linear|
searcher=web|searcher=blog|searcher=video|searcher=local|
initialsearch=NYC|resultid=somedivid|place=New York,NY]

to the GajaxsearchMacro.js page and then the same code to a node after setting up filter rule. Any ideas? I would really like to get this module into a page!

#3

rmahon - February 27, 2008 - 12:46

I gave up and installed Goggles custom Search. For $100.00 a year you can get rid of the ad's.
Bonus feature I have a multi site set up with 5 sub sites. Custom search returns from every ware no mater where it's located.

Regards
Ron

#4

happysnowmantech - July 12, 2008 - 23:00

I played around with this module a bit, but like Ron, ended up going with the free version of Google custom search because it was easier to set up one search engine that searched a fixed set of websites. But, I did do a hack to get the Google Ajax Search macro results to appear on a different page:

1. I generated a Google Ajax Search macro string and then copied it.

2. For the search results page, I created a page node with the PHP input option and put in this code snippet. Since I was just trying it out, I didn't validate the user input, but you need to validate it on your live site to avoid introducing any security issues.

<?php
if (isset($_GET['search'])) {
 
$search = $_GET['search']; // TODO: validate the user input to avoid security risks!!!
}

// Replace the value of $macro with your macro
// Note that the value of resultid needs to be the same as the div id below
$macro = '[googleajaxsearch|searcher=blog|resultid=results|initialsearch=' . $search . '|mode=linear|state=open|target=blank|resultsize=large|nsorder=date]';

$output = googleajaxsearch_filter('process', 0, -1, $macro);
print(
$output);
?>

<div id="results"></div>

3. For the search form on a separate page, I created a custom block with the PHP input option and put this code in it:

<?php
function my_googleajax_search_form(&$form_state) {
 
$form[$form_id]['search'] = array(
   
'#title' => t('Search featured blogs'),
   
'#type' => 'textfield',
   
'#size' => 15,
   
'#default_value' => '',
   
'#attributes' => array('title' => t('Enter the terms you wish to search for.')),
  );
 
$form['submit'] = array('#type' => 'submit', '#value' => t('Search'));
 
$form['#submit'][] = 'my_googleajax_search_form_submit';
 
// $form['#validate'][] = 'my_googleajax_search_form_validate';  // TODO: validate the user input to avoid security risks!!!

 
return $form;
}

function
my_googleajax_search_form_submit($form, &$form_state) {
 
// Replace the string 'searchresults' with the path to the node created in step #2
 
drupal_goto('searchresults', 'search=' . $form_state['values']['search']);
}
?>


<?php
print drupal_get_form('my_googleajax_search_form');
?>

#5

mac_perlinski - October 13, 2009 - 19:47
Status:active» closed
 
 

Drupal is a registered trademark of Dries Buytaert.