OK, here's what I came up with...I surrounded the form tag and the submit button with an if statement to determine if we're in https....the form tag has to be included due to the enter key automatically submitting the form. I used JS because we needed to get the value from the text box to dynamically define the link. Here's the code from tpl_search.php...
PHP Code:
$content = "";
$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent centeredContent">';
if ($_SERVER["HTTPS"]) {//yes, this is a secure page
$content .= zen_draw_form('quick_find', 'JavaScript:window.location="http://www.mywebsite.com/index.php?main_page=advanced_search_result&search_in_description=1&keyword=" + document.quick_find.keyword.value', 'get');
}else{
$content .= zen_draw_form('quick_find', zen_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get');
}
$content .= zen_draw_hidden_field('main_page',FILENAME_ADVANCED_SEARCH_RESULT);
$content .= zen_draw_hidden_field('search_in_description', '1') . zen_hide_session_id();
if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes') {
$content .= zen_draw_input_field('keyword', '', 'size="18" maxlength="100" style="width: ' . ($column_width-30) . 'px"') . '<br />';
if ($_SERVER["HTTPS"]) {//yes, this is a secure page
$content .= '<a href=\'JavaScript:window.location="http://www.mywebsite.com/index.php?main_page=advanced_search_result&search_in_description=1&keyword=" + document.quick_find.keyword.value\' name="searchLink">Search</a>';
}else{
$content .= zen_image_submit (BUTTON_IMAGE_SEARCH,HEADER_SEARCH_BUTTON);
}
$content .= '<br /><a href="' . zen_href_link(FILENAME_ADVANCED_SEARCH) . '">' . BOX_SEARCH_ADVANCED_SEARCH . '</a>';
} else {
$content .= zen_draw_input_field('keyword', '', 'size="18" maxlength="100" style="width: ' . ($column_width-30) . 'px" value="' . HEADER_SEARCH_DEFAULT_TEXT . '" onfocus="if (this.value == \'' . HEADER_SEARCH_DEFAULT_TEXT . '\') this.value = \'\';" onblur="if (this.value == \'\') this.value = \'' . HEADER_SEARCH_DEFAULT_TEXT . '\';"') . '<br />';
if ($_SERVER["HTTPS"]) {//yes, this is a secure page
$content .= '<a href=\'JavaScript:window.location="http://www.mywebsite.com/index.php?main_page=advanced_search_result&search_in_description=1&keyword=" + document.quick_find.keyword.value\' name="searchLink">Search</a>';
}else{
$content .= '<input type="submit" value="' . HEADER_SEARCH_BUTTON . '" style="width: 50px" />';
}
$content .= '<br /><a href="' . zen_href_link(FILENAME_ADVANCED_SEARCH) . '">' . BOX_SEARCH_ADVANCED_SEARCH . '</a>';
}
$content .= "</form>";
$content .= '</div>';
I'm sure this could be cleaner but I've found that it's easier for future upgrades this way. Of course, this is in my template override directory! It works like a charm unless JS is disabled - checked in FF1.5, IE7 and Opera9. I'll add a button image in the link to make it look prettier.
Any ideas on how to check if JS is disabled, so we could display the original elements (even though they'd get a security warning)? In my test case, which was writing the html code directly, I used <noscript> tags to write out the original elements, then checked for the existence of that element before writing the JS version. It works great...but I don't think that'll work with the search sidebox template due to the way it's developed as a string.
Next is the manufacturer's sidebox!!
Patti
Bookmarks