View Single Post
Old 02-28-2004, 11:24 PM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
>> i tried several solutions - all of them work well - but i don't like them at all...

Hi. Just curious, if they all work well, why don't you like them? :confused:

Anyway, the following was not tested much so you'll need to check it.

First in function_phpdig_form.php replace the following:
PHP Code:
$result['form_head'] = "<form action='$result_page' method='get'>
<input type='hidden' name='site' value='$site'/>
<input type='hidden' name='path' value='$path'/>
<input type='hidden' name='result_page' value='$result_page'/>
"

with the following:
PHP Code:
$dropdown_flag 0;
$relative_script_path '.';
if (
is_file("$relative_script_path/includes/connect.php")) {
    include 
"$relative_script_path/includes/connect.php";
}
else {
    die (
"Unable to find connect.php file for dropdown menu.\n");
}
if (isset(
$site) && is_numeric($site) && ($site 0)) {
    
$site = (int) $site;
    
$dd_query mysql_query('SELECT DISTINCT path FROM '.PHPDIG_DB_PREFIX.'spider WHERE site_id = '.$site.' AND path != ""',$id_connect);
    if (@
mysql_num_rows($dd_query) > 0) {
        
$result['form_head'] = "<form action='$result_page' method='get'>
        <input type='hidden' name='site' value='$site'/>
        <input type='hidden' name='refine' value='1'/>
        <input type='hidden' name='result_page' value='$result_page'/>"
;
        
$result['form_dropdown'] = "Select a path to search: <select name='path'>";
        while (
$dd_data mysql_fetch_array($dd_query)) {
            if (
$path == $dd_data['path']) {
                
$result['form_dropdown'] .= "<option value='".$dd_data['path']."' selected>".$dd_data['path']."</option>";
            }
            else {
                
$result['form_dropdown'] .= "<option value='".$dd_data['path']."'>".$dd_data['path']."</option>";
            }
        }
        
$result['form_dropdown'] .= "</select> <a href=\"$result_page\">Restart</a>";
    }
    else {
        
$dropdown_flag 1;
    }
}
else {
    
$dropdown_flag 1;
}
if (
$dropdown_flag == 1) {
    
$dd_query mysql_query('SELECT site_id,site_url FROM '.PHPDIG_DB_PREFIX.'sites',$id_connect);
    
$result['form_head'] = "<form action='$result_page' method='get'>
    <input type='hidden' name='path' value='$path'/>
    <input type='hidden' name='refine' value='1'/>
    <input type='hidden' name='result_page' value='$result_page'/>"
;
    
$result['form_dropdown'] = "Select a site to search: <select name='site'>";
    while (
$dd_data mysql_fetch_array($dd_query)) {
        
$result['form_dropdown'] .= "<option value='".$dd_data['site_id']."'>".$dd_data['site_url']."</option>";
    }
    
$result['form_dropdown'] .= "</select> <a href=\"$result_page\">Restart</a>";

Next in search.php add the indicated line:
PHP Code:
extract(phpdigHttpVars(
     array(
'query_string'=>'string',
           
'refine'=>'integer',
           
'refine_url'=>'string',
           
'site'=>'integer',
           
'limite'=>'integer',
           
'option'=>'string',
           
'lim_start'=>'integer',
           
'browse'=>'integer',
           
'path'=>'string'
           
)
     ));

if (
$site <= 0) { $query_string ""; } // add this line here

phpdigSearch($id_connect$query_string$option$refine,
              
$refine_url$lim_start$limite$browse,
              
$site$path$relative_script_path$template); 
Then in a template, say the phpdig.html file, add <phpdig:form_dropdown/> like so:
Code:
 <tr>
 <td class="greyForm">
 <phpdig:form_radio/>
 </td>
 </tr>

 <tr>
 <td class="greyForm">
 <phpdig:form_dropdown/>
 </td>
 </tr>

</table>
<phpdig:form_foot/>
If you want to use an array $varname['form_dropdown'] would also be available using this code.

When you call search.php you'll get a drop down of sites to search, and then you'll get a drop down of paths within that site to search.

Of course, TMTOWTDI and remember to remove any "word" wrapping in the above code.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote