osCommerce and osCMax shopping cart software forums

Shopping Cart Software

osCommerce with teeth!

 
 

File diff from OSC advanced_search.php

This is a discussion on File diff from OSC advanced_search.php within the osCMax v2 Customization/Mods forums, part of the osCMax v2.0 Forums category; Hi, I am customizing and installing Product Extra Fields, and so far it was working fine, but I needed and ...


Go Back   osCommerce and osCMax shopping cart software forums > osCMax v2.0 Forums > osCMax v2 Customization/Mods

Register FAQ Members List Calendar Mark Forums Read


Free community membership! Fast easy FREE membership
Reply

 

LinkBack Thread Tools
  #11  
Old 07-13-2008, 07:06 PM
osCMax Testing Team
 
Join Date: Oct 2003
Posts: 52
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
icecold
Default Re: File diff from OSC advanced_search.php

Hi,

I am customizing and installing Product Extra Fields, and so far it was working fine, but I needed and additional feature not included in the package so I started to browse the code and modify it, then I realize something was missing from the installation, and when I added I start to get this error : 'Parse error: syntax error, unexpected T_ELSE in /home/... line 55'

When I read the instructions I found a discrepancy between OSCMax and the code, which is understandable, as some lines that used to be in advanced_search.php in OScMAx are instead in advanced_search_result.php. Particularly this portion(Please read my comments added to the original code):
PHP Code:
//This section validates user input in the form to make sure fields are not empty the contrib instructs to search for it in advanced_search but this code is slightly modified and present in advanced_search_result.php

 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)) ) {
    error_message = error_message + "* <?php echo ERROR_AT_LEAST_ONE_INPUT?>\n";
//This is what is not in OscMax code     
error_field = document.advanced_search.keywords;
    error_found = true;
  }
and CHANGE them to read as follows://These changes are in the contrib installation text
because of BTS there are already in php
This is completely useless in oscMax code because it uses a different way to validate those fields
PHP Code:
<?php
// START: Extra Fields Contribution Search Fields 1.0
foreach ($pef_fields as $field)
{
    echo 
'  var pef_'.$field['products_extra_fields_id'].' = document.advanced_search.pef_'.$field['products_extra_fields_id'].".value;\n";// Some javascript call?

}
?>
// This is slightly different in oscMax as the user input validation uses a different if

  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)) 
<?php
//Here is where my problem starts, as this foreach statement inside the IF, is causing the syntax error >> My knowledge of php is limited so I don't understand why is not working

// START: Product Extra Fields Contribution Search Fields 1.0
foreach ($pef_fields as $field)
{
    
$fieldid =  'pef_'.$field['products_extra_fields_id'];
    echo 
" && (( $fieldid == '' ) || ($fieldid.length < 1))";
}
// END: Extra Fields Contribution
?>
ok here is my modified code ... >>>
Please note I validated additional fields and has a slight modification from the oscMax original before adding this missing code.
PHP Code:
  $error false;
//I inserted these lines and then commented out after realizing it wasn't working
// START: Extra Fields Contribution Search Fields 1.0
/*foreach ($pef_fields as $field)
{
    echo '  var pef_'.$field['products_extra_fields_id'].' = document.advanced_search.pef_'.$field['products_extra_fields_id'].".value;\n";
}*/ 

//end comments

//My modified IF with additional ANDs added in order to validate some of my fields

  
if ( (isset($HTTP_GET_VARS['keywords']) && empty($HTTP_GET_VARS['keywords'])) &&
       (isset(
$HTTP_GET_VARS['dfrom']) && (empty($HTTP_GET_VARS['dfrom']) || ($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING))) &&
       (isset(
$HTTP_GET_VARS['dto']) && (empty($HTTP_GET_VARS['dto']) || ($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING))) &&
       
// $afrom, $hfrom, $ato and $hto added to the code
       
(isset($HTTP_GET_VARS['afrom']) && !is_numeric($HTTP_GET_VARS['afrom'])) &&
       (isset(
$HTTP_GET_VARS['ato']) && !is_numeric($HTTP_GET_VARS['ato'])) &&
       (isset(
$HTTP_GET_VARS['hfrom']) && !is_numeric($HTTP_GET_VARS['hfrom'])) &&
       (isset(
$HTTP_GET_VARS['hto']) && !is_numeric($HTTP_GET_VARS['hto'])) &&
       
//end additions
       
(isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom'])) &&
       (isset(
$HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto'])) ) 
    
// Here is where the issues started. After I added those lines to the FOreach statement...
My problem was I needed to display some of the fields as a Select type field but if I don't validate them then the system returned the error 'empty field ...'

  
        // START: Product Extra Fields Contribution Search Fields 1.0
foreach ($pef_fields as $field)
{
    $fieldid =  '
pef_'.$field['products_extra_fields_id'];
    echo " && (( $fieldid == ' 
) || ($fieldid.length 1))";
}
// END: Extra Fields Contribution 
Any ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Advertisement
  #12  
Old 07-13-2008, 07:11 PM
osCMax Testing Team
 
Join Date: Oct 2003
Posts: 52
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
icecold
Default Re: File diff from OSC advanced_search.php

I am not able to edit anything I am quoting but using [php] tags, with my previous code, sorry for the mess!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13  
Old 07-13-2008, 07:13 PM
osCMax Testing Team
 
Join Date: Oct 2003
Posts: 52
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
icecold
Default Re: File diff from OSC advanced_search.php

Thanks for replying in fact it was a missing }
After much searching I found out there was also a validating function inside advanced_search.js.php
Now I want to validate a select, because the current validation from the contribution, but I don't know which function it must be used or if have to create a new one. The only function that seems to check the form is >>>
PHP Code:
<?php
// START: Extra Fields Contribution Search Fields 1.0
$pef_fields = array();
$pef_fields_query tep_db_query("SELECT products_extra_fields_id, products_extra_fields_name FROM " TABLE_PRODUCTS_EXTRA_FIELDS " WHERE (languages_id = 0 OR languages_id = " . (int)$languages_id ") AND products_extra_fields_status ORDER BY products_extra_fields_order");
while (
$field tep_db_fetch_array($pef_fields_query))
  {
    
$pef_fields[] = $field;
  }
// END: Extra Fields Contribution
?>
Code:
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;
 //Start Age and Height Variables mod added
  var afrom = document.advanced_search.afrom.value;
  var ato = document.advanced_search.ato.value;
  var afrom_float;
  var ato_float;
  //height
  var hfrom = document.advanced_search.hfrom.value;
  var hto = document.advanced_search.hto.value;
  var hfrom_float;
  var hto_float;
  //End
  var pfrom = document.advanced_search.pfrom.value;
  var pto = document.advanced_search.pto.value;
  var pfrom_float;
  var pto_float;

 <!-- /*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)) )*/ -->
PHP Code:
  <?php
// START: Extra Fields Contribution Search Fields 1.0
foreach ($pef_fields as $field)
{
    echo 
'  var pef_'.$field['products_extra_fields_id'].' = document.advanced_search.pef_'.$field['products_extra_fields_id'].".value;\n";
}
?>

  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)) 
<?php
// START: Product Extra Fields Contribution Search Fields 1.0
foreach ($pef_fields as $field)
{
    
$fieldid =  'pef_'.$field['products_extra_fields_id'];
    echo 
" && (( $fieldid == '' ) || ($fieldid.length < 1))";
}
// END: Extra Fields Contribution
?>
) {

  
    error_message = error_message + "* <?php echo ERROR_AT_LEAST_ONE_INPUT?>\n";
    error_field = document.advanced_search.keywords;
    error_found = true;
  }
This function is completely unaware of my Select type field, if I select anything from a select it always return an error 'Error At least one of the fields in the search form must be entered.', so it's validating my Select as an empty field, instead ..

Here is the portion of the code where the SELECTS are within the Advanced Search form:
PHP Code:
<!--New fields Inserted here in query-->   
               <tr>
                <td class="fieldKey"><?php echo ENTRY_HAIR?></td>
                <td class="fieldValue"><?php echo tep_draw_pull_down_menu('products_to_products_extra_fields_id'tep_get_extra(array(array('id' => '''text' => TEXT_ALL_HAIR)))); ?></td>
              </tr>
              <tr>
                <td class="fieldKey"><?php echo ENTRY_EYES?></td>
                <td class="fieldValue"><?php echo tep_draw_pull_down_menu('products_to_products_extra_fields_id'tep_get_extra1(array(array('id' => '''text' => TEXT_ALL_EYES)))); ?></td>
              </tr>
              <tr>
 <!--End new fields-->
Both are class="fieldValue" so I assumed they will be validated but that is not happening, the only difference from the default code is I used the function tep_draw_pull_down_menu(), because I wanted them to be a SELECT type, instead of INPUT field.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14  
Old 07-13-2008, 07:17 PM
osCMax Testing Team
 
Join Date: Oct 2003
Posts: 52
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
icecold
Default Re: Empty Select in advanced_search_result.php

I don't understand why the values of my select end up empty

http://.../advanced_search_result.ph...09%2F07%2F2008

I have a SELECT pulldown menu in my advanced search form >>>
PHP Code:
<tr>
                <td class="fieldKey"><?php echo ENTRY_HAIR?></td>
                <td class="fieldValue"><?php echo tep_draw_pull_down_menu('products_to_products_extra_fields_id'tep_get_hair(array(array('id' => '''text' => TEXT_ALL_HAIR)))); ?></td>
              </tr>
              <tr>
                <td class="fieldKey"><?php echo ENTRY_EYES?></td>
                <td class="fieldValue"><?php echo tep_draw_pull_down_menu('products_to_products_extra_fields_id'tep_get_eyes(array(array('id' => '''text' => TEXT_ALL_EYES)))); ?></td>
              </tr>
The pull down shows fine all values, for instance Hair has the options:
Please Select >>> Blond >>> Brunette

If either one is selected the SELECT type behaves like is the option is Please SELECT as you can see above. My function 'tep_get_hair' added to general_output.php under includes/functions/
PHP Code:
function tep_get_hair($hair_array '') {
    if (!
is_array($hair_array)) $hair_array = array();

    
$hair_query tep_db_query("select products_extra_fields_value from " TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS " where products_extra_fields_id = '1'");
    while (
$hair tep_db_fetch_array($hair_query)) {
      
$hair_array[] = array('id' => $hair['products_extra_fields_id'], 'text' => $hair['products_extra_fields_value']);
    }

    return 
$hair_array;
  } 
Browses the table and selects the values where the products extra fields id is 1, which is the id for the extra field Hair.
When I check at the source of the browser's output in the advanced search form I noticed>>>
HTML Code:
td class="fieldKey">Hair:</td>

                <td class="fieldValue"><select name="products_to_products_extra_fields_id"><option value="" selected="selected">Please Select</option><option value="" selected="selected">Blond</option><option value="" selected="selected">Brunette</option></select></td>
              </tr>
              <tr>
                <td class="fieldKey">Eyes:</td>
                <td class="fieldValue"><select name="products_to_products_extra_fields_id"><option value="" selected="selected">Please Select</option><option value="" selected="selected">Green</option><option value="" selected="selected">Hazel</option></select></td> 
I noticed all option values are EMPTY! is this because of the way I retrieve these values from my table?
Should I create another table and refer to it instead?

All extra fields are validated in .js and php ... so why I don't get any values from those selects?[/quote]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Advertisement
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
No access to php.ini file! crystina osCMax v2 Installation issues 3 04-05-2007 08:25 PM
file diff software chrismole Off topic & Chit Chat 4 01-15-2007 09:58 PM
Hello i need help with my english.php file reysent osCommerce 2.2 Modification Help 6 02-20-2005 09:28 AM
Error on checkout_process.php file ...please help ??? nrwalker osCommerce 2.2 Modification Help 1 06-28-2004 06:19 PM
check_ip.php missing file? AtroxAngel osCommerce 2.2 Installation Help 1 01-24-2003 07:04 AM


All times are GMT -8. The time now is 02:21 AM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO
http://www.oscmax.com/forums/
Copyright 2008 osCMax