ivandong Posted April 18, 2008 Posted April 18, 2008 Hi, i have an installation of OScommerce on my website, I am using it for a Real Estate company, so i made some modifications so it works better for my objetive. Website: English: http://hermosillo-bienesraices.com/index.php?language=en Spanish: http://hermosillo-bienesraices.com/index.php?language=es I changed the "Quick Search Box" and added some new fields: "City" = Categories "Zone" = Manufacterers ...and Price range. Quick Search box CODE: $info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'), 'text' => '<table vertical-align="center" border="0" width="100%" cellspacing="10" cellpadding="1"> <tr><td class="infoBoxContents" valign="top" colspan="3">' . BOX_ADVSEARCH_CAT . '</td></tr> <tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => BOX_ADVSEARCH_ALLCAT)))) . '</td></tr> <tr><td class="infoBoxContents" valign="top" colspan="3">' . BOX_ADVSEARCH_ZONE . '</td></tr> <tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_pull_down_menu('manufacters_id', tep_get_manufacturers(array(array('id' => '', 'text' => BOX_ADVSEARCH_ALLZONE)))) . '</td></tr> <tr><td class="infoBoxContents" valign="top" colspan="3">' . BOX_ADVSEARCH_PRICERANGE . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">$' . tep_draw_input_field('pfrom','','size="4" maxlength="8"') . BOX_ADVSEARCH_PRICESEP . tep_draw_input_field('pto','','size="4" maxlength="8"') . '</td></tr> <tr><td class="infoBoxContents" valign="top" colspan="3"> </td></tr><tr><td class="infoBoxContents" valign="top" colspan="3"><center>' . tep_image_submit('button_search.gif', BOX_HEADING_ADVSEARCH) . '</center></td></tr></table>'); As you can see Im using Extra Fields for the products. I have an extrafield called "Type" so you can select if you are looking for a House, Apartment, Building or Land and another one called "For" where you can select if you want to BUY or RENT the property. As you can see here: The task I want to complete is to add those two fields into the Quick Search box and depending on the selection it displays the results correctly. Im aware i have to make a modification of "advanced_search_result.php" file and work with tep_draw_input_field function in the box file. If anyone can help me thru this i will really apreciatte it because I am in a death line right now. Thank you very much. Iván Martínez
ivandong Posted April 25, 2008 Author Posted April 25, 2008 I already manage the way to list extra fields values. I created a function calle tep_get_type but I am still having a little problem with it. function tep_get_type($type_array = '') { if (!is_array($type_array)) $type_array = array(); if ($language == "espanol") { $type_query = tep_db_query("SELECT DISTINCT products_extra_fields_id,products_extra_fields_value FROM products_to_products_extra_fields WHERE products_Extra_fields_id =31"); } else { $type_query = tep_db_query("SELECT DISTINCT products_extra_fields_id,products_extra_fields_value FROM products_to_products_extra_fields WHERE products_Extra_fields_id =32"); } while ($ptype = tep_db_fetch_array($type_query)) { $type_array[] = array('id' => $ptype['products_extra_fields_id'], 'text' => $ptype['products_extra_fields_value']); } return $type_array; } As you can see im using a if statment "if ($language == "espanol") {". But im getting the results in English, and i cannot read the variable $language, I already tried with $languages_id, too. Wich is the correct variable or correct way to do this in order to get the results in both languages? Thanks.
ivandong Posted April 25, 2008 Author Posted April 25, 2008 ADD NEW FIELDS FOR EXTRA FIELDS CONTRIBUTION I couldn't read the variable $language directly form the function because is not a global variable so i made a little change on the function: function tep_get_type($type_array = '',$language) { if (!is_array($type_array)) $type_array = array(); if ($language == "english") { $type_query = tep_db_query("SELECT DISTINCT products_extra_fields_id,products_extra_fields_value FROM products_to_products_extra_fields WHERE products_Extra_fields_id =32"); } else { $type_query = tep_db_query("SELECT DISTINCT products_extra_fields_id,products_extra_fields_value FROM products_to_products_extra_fields WHERE products_Extra_fields_id =31"); } while ($ptype = tep_db_fetch_array($type_query)) { $type_array[] = array('id' => $ptype['products_extra_fields_id'], 'text' => $ptype['products_extra_fields_value']); } return $type_array; } Added 2 arguments to the function. $type_array and $language. In order to use the function use this: <tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_pull_down_menu('type_id', tep_get_type(array(array('id' => '', 'text' => '')),$language)) . '</td></tr> Know im going to play with advanced_search_result so i can list the products results correctly. Any suggestion?
alba Posted May 3, 2008 Posted May 3, 2008 ADD NEW FIELDS FOR EXTRA FIELDS CONTRIBUTION I couldn't read the variable $language directly form the function because is not a global variable so i made a little change on the function: function tep_get_type($type_array = '',$language) { if (!is_array($type_array)) $type_array = array(); if ($language == "english") { $type_query = tep_db_query("SELECT DISTINCT products_extra_fields_id,products_extra_fields_value FROM products_to_products_extra_fields WHERE products_Extra_fields_id =32"); } else { $type_query = tep_db_query("SELECT DISTINCT products_extra_fields_id,products_extra_fields_value FROM products_to_products_extra_fields WHERE products_Extra_fields_id =31"); } while ($ptype = tep_db_fetch_array($type_query)) { $type_array[] = array('id' => $ptype['products_extra_fields_id'], 'text' => $ptype['products_extra_fields_value']); } return $type_array; } Added 2 arguments to the function. $type_array and $language. In order to use the function use this: <tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_pull_down_menu('type_id', tep_get_type(array(array('id' => '', 'text' => '')),$language)) . '</td></tr> Know im going to play with advanced_search_result so i can list the products results correctly. Any suggestion? Ive had several goes at getting the advanced_search_results code working properly for the extra fields, mostly with no joy whatsoever... If you have any luck let me know
Recommended Posts
Archived
This topic is now archived and is closed to further replies.