In trying fix an issue with the search engine where price from and price to do not go into the text boxes all the time, I've hit a snag that I can't explain and don't understand.
My understanding of the process is that it starts in tpl_search_default.php and uses the $sData values from modules/pages/search/header_php.php...like so.
PHP Code:
$sData['pto'] = (isset($_GET['pto']) ? zen_output_string($_GET['pto']) : '');
For troubleshooting purposes, I changed the above code to the code below...using 1000, '1000', and "1000" at many different points in my testing.
PHP Code:
$sData['pto'] = 1000;
In tpl_search_default.php, line 37, I tested if $sData['pto'] was available and correct...like so.
PHP Code:
<?php print_r('$sData[pto] before sanitizing = ' . $sData['pto'] . '<br>'); //this is not making it's way into zen_draw_input_field('pto', $sData['pto'], 'id="pto"'); below
?>
<div id="searchPriceTo"><label for="pto"><?php echo ENTRY_PRICE_TO; ?></label><?php echo zen_draw_input_field('pto', $sData['pto'], 'id="pto"'); ?></div>
It is available and correct but it is not getting into the text box.
So I moved on to verifying function zen_draw_input_field in the html_output.php file.
Around line 585, I tested for $value ($sData...).
PHP Code:
print_r('VALUE = ' . $value);
$field = '<input type="' . zen_output_string($type) . '" name="' . zen_sanitize_string(zen_output_string($name)) . '"';
if (isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && $reinsert_value == true) {
$field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
} elseif (zen_not_null($value)) {
$field .= ' value="' . zen_output_string($value) . '"';
}
print_r('FIELD = ' . $field . ' | VALUE = ' . $value);
$value is still correct and available but it still isn't inside of the text box...but it should be, right? The empty text box appears at is should...other than being empty.
My confusion comes here while anylizing the above code. Why would you use $name in any part of this if statement below? The goal is to set $field .= ' value=" to the $value...not the $name, right?
PHP Code:
if (isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && $reinsert_value == true) {
$field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
}
So, I changed $name to $value and the text box now has the correct value in it.
Now, I'm reluctant to leave it this way because this function is WIDELY used throughout the programming.
My question, is this a good fix and a BUG?
I have no idea where the search engine NOTIFY system is located nor do I understand how the "watcher class" system works...so I couldn't analyze it.
I would appreciate some insight and help please.
Bookmarks