PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   How-to Forum (http://www.phpdig.net/forum/forumdisplay.php?f=33)
-   -   Search Template/Array (http://www.phpdig.net/forum/showthread.php?t=580)

tomas 02-27-2004 06:35 PM

Search Template/Array
 
hi charter,

1) using search with template - how to include a drop-down
menu to select different parts (paths) of website to be searched
2) using search with array only

i tried several solutions - all of them work well - but i don't like
them at all :-)
so - you would do me a great favour - posting two COMPLETE solutions - the way YOU would do it

thanks again
tomas

Charter 02-28-2004 11:24 PM

>> 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.


All times are GMT -8. The time now is 09:12 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.