Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Search (in header) doesn't filter the result by chosen field


mariorr

Recommended Posts

Posted

Hi, I have moved the advanced search to header, but when I submit a search this is not accurate, I mean, if I look through a field size 70, I get back all the items of the catalog, the search doesn't filter the result by the chosen field. This only happens if I put the file advanced_search in the header , if I don't move it to header, the search is accurate. Could someone take a look at code and tell me what can I miss?.

 

Sorry about my poor english

Thanks a lot.

 

 

Atacch the box search code that include the advanced search code.

 

<?php
/*
 $Id: search.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/



 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH);

 $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH));
?>




<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<link rel="stylesheet" type="text/css" href="stylesheet.css">
<?php

// begin Extra Product Fields

   $epf_query = tep_db_query("select e.epf_id, e.epf_uses_value_list, l.epf_label from " . TABLE_EPF . " e join " . TABLE_EPF_LABELS . " l where e.epf_status and e.epf_advanced_search and (e.epf_id = l.epf_id) and (l.languages_id = " . (int)$languages_id . ") and l.epf_active_for_language order by e.epf_order");

   $epf = array();

   while ($e = tep_db_fetch_array($epf_query)) {

     $epf[] = array('id' => $e['epf_id'],

                    'label' => $e['epf_label'],

                    'uses_list' => $e['epf_uses_value_list'],

                    'field' => 'extra_value' . ($e['epf_uses_value_list'] ? '_id' : '') . $e['epf_id']);

   }

// end Extra Product Fields

?>

<script language="javascript" src="includes/general.js"></script>
<script language="javascript"><!--
function check_form() {
 var error_message = "<?php echo JS_ERROR; ?>";
 var error_found = false;
 var error_field;
 var keywords = document.advanced_search.keywords.value;
 var dfrom = document.advanced_search.dfrom.value;
 var dto = document.advanced_search.dto.value;
 var pfrom = document.advanced_search.pfrom.value;
 var pto = document.advanced_search.pto.value;
 var pfrom_float;
 var pto_float;

// begin Extra Product Fields

 var cat = document.advanced_search.categories_id.value;

 var mfg = document.advanced_search.manufacturers_id.value;

<?php

foreach ($epf as $e)

{

echo '  var epf' . $e['id'] . ' = document.advanced_search.' . $e['field'] . ".value;\n";

}

?>

// end Extra Product Fields



 if ( ((keywords == '') || (keywords.length < 1)) && ((dfrom == '') || (dfrom == '<?php echo DOB_FORMAT_STRING; ?>') || (dfrom.length < 1)) && ((dto == '') || (dto == '<?php echo DOB_FORMAT_STRING; ?>') || (dto.length < 1)) && ((pfrom == '') || (pfrom.length < 1)) && ((pto == '') || (pto.length < 1))

 // begin Extra Product Fields

  && (cat == '') && (mfg == '')

<?php

foreach ($epf as $e)

{

$fieldid =  'epf' . $e['id'];

echo " && (( $fieldid == '' ) || ($fieldid.length < 1))";

}

?>

// end Extra Product Fields

) {

   error_message = error_message + "* <?php echo ERROR_AT_LEAST_ONE_INPUT; ?>\n";

   error_field = document.advanced_search.keywords;
   error_found = true;
 }

 if ((dfrom.length > 0) && (dfrom != '<?php echo DOB_FORMAT_STRING; ?>')) {
   if (!IsValidDate(dfrom, '<?php echo DOB_FORMAT_STRING; ?>')) {
     error_message = error_message + "* <?php echo ERROR_INVALID_FROM_DATE; ?>\n";
     error_field = document.advanced_search.dfrom;
     error_found = true;
   }
 }

 if ((dto.length > 0) && (dto != '<?php echo DOB_FORMAT_STRING; ?>')) {
   if (!IsValidDate(dto, '<?php echo DOB_FORMAT_STRING; ?>')) {
     error_message = error_message + "* <?php echo ERROR_INVALID_TO_DATE; ?>\n";
     error_field = document.advanced_search.dto;
     error_found = true;
   }
 }

 if ((dfrom.length > 0) && (dfrom != '<?php echo DOB_FORMAT_STRING; ?>') && (IsValidDate(dfrom, '<?php echo DOB_FORMAT_STRING; ?>')) && (dto.length > 0) && (dto != '<?php echo DOB_FORMAT_STRING; ?>') && (IsValidDate(dto, '<?php echo DOB_FORMAT_STRING; ?>'))) {
   if (!CheckDateRange(document.advanced_search.dfrom, document.advanced_search.dto)) {
     error_message = error_message + "* <?php echo ERROR_TO_DATE_LESS_THAN_FROM_DATE; ?>\n";
     error_field = document.advanced_search.dto;
     error_found = true;
   }
 }

 if (pfrom.length > 0) {
   pfrom_float = parseFloat(pfrom);
   if (isNaN(pfrom_float)) {
     error_message = error_message + "* <?php echo ERROR_PRICE_FROM_MUST_BE_NUM; ?>\n";
     error_field = document.advanced_search.pfrom;
     error_found = true;
   }
 } else {
   pfrom_float = 0;
 }

 if (pto.length > 0) {
   pto_float = parseFloat(pto);
   if (isNaN(pto_float)) {
     error_message = error_message + "* <?php echo ERROR_PRICE_TO_MUST_BE_NUM; ?>\n";
     error_field = document.advanced_search.pto;
     error_found = true;
   }
 } else {
   pto_float = 0;
 }

 if ( (pfrom.length > 0) && (pto.length > 0) ) {
   if ( (!isNaN(pfrom_float)) && (!isNaN(pto_float)) && (pto_float < pfrom_float) ) {
     error_message = error_message + "* <?php echo ERROR_PRICE_TO_LESS_THAN_PRICE_FROM; ?>\n";
     error_field = document.advanced_search.pto;
     error_found = true;
   }
 }

 if (error_found == true) {
   alert(error_message);
   error_field.focus();
   return false;
 } else {
   RemoveFormatString(document.advanced_search.dfrom, "<?php echo DOB_FORMAT_STRING; ?>");
   RemoveFormatString(document.advanced_search.dto, "<?php echo DOB_FORMAT_STRING; ?>");
   return true;
 }
}

function popupWindow(url) {
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=550,height=680,screenX=150,screenY=150,top=50,left=300')
}
//--></script>







<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>






   <td width="100%" valign="top"><?php echo tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get', 'onSubmit="return check_form(this);"') . tep_hide_session_id(); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="infoBoxHeading" height="22"><?php echo tep_draw_separator('pixel_trans.gif', '11', '1'); ?><?php echo HEADING_TITLE_1; ?></td>
         </tr>
       </table></td>
     </tr>
<?php
 if ($messageStack->size('search') > 0) {
?>
     <tr>
       <td><?php echo $messageStack->output('search'); ?></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
 }
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBox">
         <tr class="infoBoxContents">
           <td align="left"><table border="0" width="50%" cellspacing="0" cellpadding="0">
		  <tr>
               <td class="fieldKey"><?php echo tep_draw_separator('pixel_trans.gif', '11', '1'); ?><?php echo ENTRY_CATEGORIES; ?></td>
               <td class="fieldValue"><?php echo tep_draw_separator('pixel_trans.gif', '5', '1'); ?><?php echo tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)))); ?></td>
             </tr>
             <tr>
               <td class="fieldKey"> </td>
               <td class="smallText"><?php echo tep_draw_checkbox_field('inc_subcat', '1', true) . ' ' . ENTRY_INCLUDE_SUBCATEGORIES; ?></td>
             </tr>
             <tr>
               <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
             </tr>
             <tr>
               <td class="fieldKey" align="right"><?php echo tep_draw_separator('pixel_trans.gif', '11', '1'); ?><?php echo ENTRY_MANUFACTURERS; ?><?php echo tep_draw_separator('pixel_trans.gif', '5', '1'); ?></td>
               <td class="fieldValue"><?php echo tep_draw_separator('pixel_trans.gif', '5', '1'); ?><?php echo tep_draw_pull_down_menu('manufacturers_id', tep_get_manufacturers(array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS)))); ?></td>
             </tr>
             <tr>
               <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
             </tr></table></td>
             <td align="left"><table border="0" width="50%" cellspacing="0" cellpadding="0">
		  <?php

// begin Extra Product Fields

   foreach ($epf as $e) {
?>
             <tr>
               <td class="fieldKey"><?php echo $e['label']; ?></td>
               <td class="fieldValue">
               <?php if ($e['uses_list']) {
                 echo tep_draw_pull_down_menu($e['field'], tep_build_epf_pulldown($e['id'], $languages_id, array(array('id' => '', 'text' => TEXT_ANY_VALUE))));
               } else {
                 echo tep_draw_input_field($e['field'], '', 'style="width: 300px"');
               } ?>
               </td>
             </tr>
             <tr>
               <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
             </tr>
<?php
} 
// end Extra Product Fields
?>

           </table></td>
         </tr>
       </table>
         <tr>
            <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '20'); ?></td>
         </tr>
         <tr>
           <td class="smallText"><?php echo tep_draw_separator('pixel_trans.gif', '11', '1'); ?><?php echo '<a href="javascript:popupWindow(\'' . tep_href_link(FILENAME_POPUP_SEARCH_HELP) . '\')">' . TEXT_SEARCH_HELP_LINK . '</a>'; ?></td>
           <td class="smallText" align="right"><?php echo tep_image_submit('button_search.png', IMAGE_BUTTON_SEARCH); ?><?php echo tep_draw_separator('pixel_trans.gif', '11', '1'); ?></td>
         </tr>
       </table></td>
       </tr></td>
     </tr>
   </table></form></td>






 </tr>
</table>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...