Building a Custom Results Page
ITS Web Services has developed a PHP script which parses the XML results from USC's Google Site Search (GSS) and and presents them as CSS-tagged XHTML. Site maintainers can design their own results pages and include the PHP script in the location where search results should be displayed. The CSS tags allow designers to apply custom styles to their search results.
A working demo can be viewed at http://www.usc.edu/search/gss-demo/.
Procedure
<?php
include ('/www/assets/php/curl_inc.php');
$ref='http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
$querystr = $_SERVER['QUERY_STRING'];
curl_inc ('http://web-app.usc.edu/webapps/gss/index.php?ref=
'.$ref.'&'.$querystr); //do not break line
?>
Note: This exact code will only work for websites on www.usc.edu. If you would like to use the included PHP script on another server, you will need to revise the code. For instance, if your server uses PHP and allows "HTTP includes," then there is no need to use PHP curl and you could instead use the code:
<?php
$ref='http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
$querystr = $_SERVER['QUERY_STRING'];
include ('http://web-app.usc.edu/webapps/gss/index.php?ref=
'.$ref.'&'.$querystr); //do not break line
?>
<?php
$remquery = $_SERVER['QUERY_STRING'];
parse_str($remquery,$testarray);
if ($testarray['q']) {
$query_term = $testarray['q'];
}
?>
and then display the search term with the code <?php echo $query_term ?>.Last updated:
November 02, 2010