PDA

View Full Version : Problem using custom search result page


passweb
09-02-2004, 01:57 PM
Greetings,

I'm trying to fit PhpDig into my CMS. Right now the indexing is working perfectly, and my search.php works flawlessly. The problem, however, is that I am trying to use a php CMS I have developed to display the search results, not the original search.php script. When I do a search, my script (which is almost identical to the search.php one, except using an array rather than a template) says that there are no search results. search.php, on the other hand, gives me plenty of results. It's like it gives me different results depending on which php page is requesting it.
Here is the code for the page that is giving me problems (this code is stored in a database, then eval'ed by my CMS):
<?php
if (isset($_REQUEST['query_string'])) {
$relative_script_path = './phpdig';
$no_connect = 0;

if (is_file("$relative_script_path/includes/config.php")) {
include "$relative_script_path/includes/config.php";
}
else {
die("Cannot find config.php file.\n");
}

if (is_file("$relative_script_path/libs/search_function.php")) {
include "$relative_script_path/libs/search_function.php";
}
else {
die("Cannot find search_function.php file.\n");
}

// extract vars
extract(phpdigHttpVars(
array('query_string'=>'string',
'refine'=>'integer',
'refine_url'=>'string',
'site'=>'string', // set to integer later
'limite'=>'integer',
'option'=>'string',
'lim_start'=>'integer',
'browse'=>'integer',
'path'=>'string'
)
));

$search=phpdigSearch($id_connect, $query_string, $option, $refine,
$refine_url, $lim_start, $limite, $browse,
0, $path, $relative_script_path, 'array','');

if (strtolower($search[result_message]) != 'noresults') {
$results = $search[results];
unset($search[results]);
$nav_bar = str_replace('search.php?','./?id=new_search&',$search[nav_bar]);
echo('<div align="center"><strong>'.$search[result_message].'</strong><br/>'.$nav_bar.'</div>');
echo('<table class="searchTable">');
foreach($results as $x)
{
// this checks for binary data, and fixes the name so it looks like
$name = $x[link_title];
if ( substr($name,0,14)=='binarydata.php')
{
$loc_f = strpos($name,"&n=")+3;
$filename = urldecode(substr($name,$loc_f,strlen($name)-$loc_f));
$loc_id = strpos($name,"?id=")+4;
$fid = substr($name,$loc_id,$loc_f-$loc_id-3);
$name = $fid . ": " .$filename;
echo('<tr><td class="searchTitle"><a href="./?id='.$fid.'">'.get_frame_title($fid).'</a> : <a href="'.$x[complete_path].'">'.$filename.'</a> ('.$x[weight].')</td></tr>');
} else { // ok its a real page, not binary data
echo('<tr><td class="searchTitle"><a href="'.$x[complete_path].'">'.$name.'</a> ('.$x[weight].')</td></tr>');
}
echo('<tr><td>'.preg_replace('/('.preg_quote($query_string).')/i','<span style="color: Red;">1</span>', $x[text]).'</td></tr>');
echo('<tr><td> </td></tr>'); // spacer row
}
echo('</table><br />');
echo('<div align="center">'.$nav_bar.'</div>');
} else {
echo('Sorry, there were no results for your search. Please refine your query.');
}


} else {
echo('No search terms specified.');
}
?>
<br />
<br />
<div align="center">Uses <a href="http://www.phpdig.net/">PhpDig</a> Search Technology</div>
Any help would be greatly appreciated. :) I've followed the examples and instructions that were in a number of threads here, so I think I've modified things so that it should work by now.

(I think I've fixed the paths, which were earlier giving me trouble... right now the dir structure looks like:

/default.php (which takes ?id= and presents whichever page in the cms was requested, eg: default.php?id=search_results)
/search.php (which I wish to not have to use but is still working)
/phpdig/ (the phpdig dir)

Charter
09-07-2004, 03:42 PM
Hi. What is the exact message you receive?

passweb
09-13-2004, 01:02 PM
Hi. What is the exact message you receive?
Sorry, there were no results for your search. Please refine your query. is what is returned.

Charter
09-13-2004, 01:18 PM
In the language pack is 'noresults' =>'No results' so try changing if (strtolower($search[result_message]) != 'noresults') to if (strtolower($search[result_message]) != 'no results') and see if it works.

passweb
09-13-2004, 02:44 PM
In the language pack is 'noresults' =>'No results' so try changing if (strtolower($search[result_message]) != 'noresults') to if (strtolower($search[result_message]) != 'no results') and see if it works. Thanks for the quick reply! Unfortunately, that did not work. :( The $search[result_message] is 'noresults' with no space. Any other ideas?

Charter
09-13-2004, 10:43 PM
It would seem then that if (strtolower($search[result_message]) != 'noresults') or rather $search[result_message] is always being returned as 'noresults' a check of whatever mods you made to the search_function.php file might lend a clue.