azpro Posted May 22, 2016 Share Posted May 22, 2016 @@Gergely Hi! I made some changes to the module for example better naming for files found around line 176 // skip header if ( $n>8 ) { //empty rows shifted in @file! // WE TRY TO FIND BETTER NAVBAR_TITLE FOR $file_title if (strpos(strtolower($line), strtolower('NAVBAR_TITLE')) !== false) { $posaz = strpos($line,','); // FIND FIRST POS OF , $file_title = substr($line, $posaz); // START STRING AFTER , $file = str_replace(array("'", ";", ",", "(", ")"),'', $file_title); // CLEAN THE STRING } // Check if the line contains the string we're looking for, and add if it does foreach ($query_exploded as $q) { if (strpos(strtolower($line), strtolower($q)) !== false) { $array[] = array('icon' => "file", 'title' => sprintf( MODULE_CONTENT_HEADER_STORE_SEARCH_PAGE, substr(basename($file), 0, -4)), 'href' => tep_href_link($file_name, null, $request_type), 'price' => null); break 2; } } } Now I need to make some changes to content_searches.min.js but can not find the unminified version. Could you post/send it or attach to module? Thanks! A Quote Link to comment Share on other sites More sharing options...
tgely Posted May 22, 2016 Author Share Posted May 22, 2016 (edited) @@azpro I have extended to multi language in execute function: ob_start(); include('ext/bootstrap-plugins/typeahead/bootstrap3-typeahead.min.js'); echo "\n"; include('ext/modules/content/header/store_search/content_searches.js'); $script = ob_get_clean(); $oscTemplate->addBlock('<script>' . $script . '</script>' . "\n", 'footer_scripts'); non-minified script: $(function(){ $("#quick_search").typeahead({ items : 15, source: function (query, process) { $.ajax({ url: 'ext/modules/content/header/store_search/content_searches.php?language=<?php echo $language_code; ?>', type: 'POST', data: 'query=' + query, dataType: 'JSON', async: true, success: function(data){ var resultList = data.map(function (item) { var link = { icon: item.icon, href: item.href, name: item.title, price: item.price}; return JSON.stringify(link); }); return process(resultList); } }) }, matcher: function (obj) { return true; }, sorter: function (items) { var beginswith = [], caseSensitive = [], caseInsensitive = [], item; while (link = items.shift()) { var item = JSON.parse(link); if (!item.name.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(JSON.stringify(item)); else if (~item.name.indexOf(this.query)) caseSensitive.push(JSON.stringify(item)); else caseInsensitive.push(JSON.stringify(item)); } return beginswith.concat(caseSensitive, caseInsensitive) }, highlighter: function (link) { var item = JSON.parse(link); return '<i class="fa fa-' + item.icon + '"></i> ' + item.name + ((item.price) ? ' (' + item.price + ')' : '') + ''; }, updater: function (link) { var item = JSON.parse(link); window.location.href = item.href; } }); }); dont forget to add $lng into globals in execute function. function execute() { global $lng; // languages if (!isset($lng) || (isset($lng) && !is_object($lng))) { include(DIR_WS_CLASSES . 'language.php'); $lng = new language; } foreach ($lng->catalog_languages as $lkey => $lvalue) { if ($lvalue['id'] == $languages_id) { $language_code = $lkey; break; } } Edited May 22, 2016 by Gergely Quote osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
milerwan Posted May 28, 2016 Share Posted May 28, 2016 (edited) 1. Great contribution that I want to put in navbar but I have a position issue when I want to place it in this area.Curiously the store_search bar takes up more space in height : I haven't got this result with "normal" search bar in the same area...Do you know how to have better integration in this area with your script? 2. Morever, when the screen is in xs size, the window of search results can sometimes get out of the screen depending found products contrary to your video shows : Would you have a solution for the window can automatically adapt to the XS size? 3. Finally I have issue with special caracter like "à, ô, ï" (etc.) when I use the search button, no product found each time.I have checked the sentence in content_searches.php but it look like your fix : urlencode(str_replace(' ', ' ', $query)) An idea of the fix to apply for french language process? Thank you very much for this amazing contribution. :thumbsup: Edited May 28, 2016 by milerwan Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
Mikepo Posted May 28, 2016 Share Posted May 28, 2016 1. Great contribution that I want to put in navbar but I have a position issue when I want to place it in this area. Curiously the store_search bar takes up more space in height : @@milerwan, how did you place the search bar in the navbar. I've been trying to do this without success. Any adivise will be very much welcome. Thanks Mike Quote osC CE live - developing osC Phoenix adding modules with no core changes(awesome and easy!) Link to comment Share on other sites More sharing options...
tgely Posted May 28, 2016 Author Share Posted May 28, 2016 1. Great contribution that I want to put in navbar but I have a position issue when I want to place it in this area. Curiously the store_search bar takes up more space in height : store_search_position_issue_inside_navbar.jpg I haven't got this result with "normal" search bar in the same area... Do you know how to have better integration in this area with your script? is it between <ul> tag? Quote osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
tgely Posted May 28, 2016 Author Share Posted May 28, 2016 3. Finally I have issue with special caracter like "à, ô, ï" (etc.) when I use the search button, no product found each time. I have checked the sentence in content_searches.php but it look like your fix : urlencode(str_replace(' ', ' ', $query)) An idea of the fix to apply for french language process? Thank you very much for this amazing contribution. :thumbsup: http://www.oscommerce.com/forums/topic/407969-store-search-bar-bs/page-2#entry1743820 Quote osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
milerwan Posted May 28, 2016 Share Posted May 28, 2016 is it between <ul> tag? I don't use this sort of tag, I kept the content block structure to transpose it to data block structure for navbar. I have created a "nb_store_search.php" in includes/modules/navbar_modules directory with "store_search.php" template file : <div class="col-sm-<?php echo $content_width; ?>"> <?php echo $search_box; ?> </div> This trick works with standard seach bar but not with your scipt. Maybe there is a better way to include your script without defective positionat the end. <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2015 osCommerce Released under the GNU General Public License */ class nb_store_search { var $code = 'nb_store_search'; var $group = 'navbar_modules_left'; var $title; var $description; var $sort_order; var $enabled = false; function nb_store_search() { $this->title = MODULE_NAVBAR_STORE_SEARCH_TITLE; $this->description = MODULE_NAVBAR_STORE_SEARCH_DESCRIPTION; if ( defined('MODULE_NAVBAR_STORE_SEARCH_STATUS') ) { $this->sort_order = MODULE_NAVBAR_STORE_SEARCH_SORT_ORDER; $this->enabled = (MODULE_NAVBAR_STORE_SEARCH_STATUS == 'True'); switch (MODULE_NAVBAR_STORE_SEARCH_PLACEMENT) { case 'Home': $this->group = 'navbar_modules_home'; break; case 'Left': $this->group = 'navbar_modules_left'; break; case 'Right': $this->group = 'navbar_modules_right'; break; } } } // function execute() { function getOutput() { global $request_type, $oscTemplate; $content_width = MODULE_NAVBAR_STORE_SEARCH_WIDTH; $search_box = tep_navbar_store_search('btn-info', (MODULE_NAVBAR_STORE_SEARCH_FUNCTIONS == 'Descriptions')); // define typeahead scripts $script = '<script src="' . tep_href_link('ext/bootstrap-plugins/typeahead/bootstrap3-typeahead.min.js', null, $request_type) . '"></script>'; $script .= '<script src="' . tep_href_link('ext/modules/content/header/store_search/content_searches.min.js', null, $request_type) . '"></script>'; $oscTemplate->addBlock($script, 'footer_scripts'); ob_start(); // include(DIR_WS_MODULES . 'content/' . $this->group . '/templates/store_search.php'); // $template = ob_get_clean(); require(DIR_WS_MODULES . 'navbar_modules/templates/store_search.php'); $data = ob_get_clean(); // $oscTemplate->addContent($template, $this->group); $oscTemplate->addBlock($data, $this->group); } function isEnabled() { return $this->enabled; } function check() { return defined('MODULE_NAVBAR_STORE_SEARCH_STATUS'); } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Search Module', 'MODULE_NAVBAR_STORE_SEARCH_STATUS', 'True', 'Do you want to add the module to your shop?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Width', 'MODULE_NAVBAR_STORE_SEARCH_WIDTH', '4', 'What width container should the content be shown in?', '6', '1', 'tep_cfg_select_option(array(\'12\', \'11\', \'10\', \'9\', \'8\', \'7\', \'6\', \'5\', \'4\', \'3\', \'2\', \'1\'), ', now())"); tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_NAVBAR_STORE_SEARCH_PLACEMENT', 'Left', 'Should the module be loaded in the Left or Right or the Home area of the Navbar?', '6', '1', 'tep_cfg_select_option(array(\'Left\', \'Right\', \'Home\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Extended Store Search Functions', 'MODULE_NAVBAR_STORE_SEARCH_FUNCTIONS', 'Standard', 'Do you want to enable search function in descriptions?', '6', '1', 'tep_cfg_select_option(array(\'Standard\', \'Descriptions\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Pages', 'MODULE_NAVBAR_STORE_SEARCH_PAGES', '" . implode(';', $this->get_default_pages()) . "', 'The pages to add the Store Search\'s results.', '6', '0', 'nb_store_search_show_pages', 'nb_store_search_pages(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_NAVBAR_STORE_SEARCH_SORT_ORDER', '520', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_NAVBAR_STORE_SEARCH_STATUS', 'MODULE_NAVBAR_STORE_SEARCH_WIDTH','MODULE_NAVBAR_STORE_SEARCH_PLACEMENT', 'MODULE_NAVBAR_STORE_SEARCH_FUNCTIONS', 'MODULE_NAVBAR_STORE_SEARCH_PAGES', 'MODULE_NAVBAR_STORE_SEARCH_SORT_ORDER'); } function get_default_pages() { return array( 'shipping.php', 'contact_us.php', 'conditions.php', 'cookie_usage.php', 'privacy.php', 'login.php', 'address_book.php', 'create_account.php', 'account_history.php', 'advanced_search.php', 'products_new.php', 'reviews.php', 'ssl_check.php', 'specials.php', 'shopping_cart.php'); } } function tep_navbar_store_search($btnclass ='btn-default', $description = true) { global $request_type; $search_link = '<div class="searchbox-margin">'; $search_link .= tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', $request_type, false), 'get', 'class="form-horizontal"'); $search_link .= ' <div class="input-group">' . tep_draw_input_field('keywords', '', 'required placeholder="' . MODULE_NAVBAR_STORE_SEARCH_PLACEHOLDER . '" id="quick_search" data-provide="typeahead" autocomplete="off" style="margin-right:-2px;"', 'search') . ' <span class="input-group-btn"><button type="submit" class="btn ' . $btnclass .'"><i class="glyphicon glyphicon-search"></i></button></span>'; if (tep_not_null($description) && ($description === true)) { $search_link .= tep_draw_hidden_field('search_in_description', '1'); } $search_link .= ' </div>'; $search_link .= '</div>'; $search_link .= tep_hide_session_id() . '</form>'; return $search_link; } function nb_store_search_show_pages($text) { return nl2br(implode("\n", explode(';', $text))); } function nb_store_search_pages($values, $key) { global $PHP_SELF; $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.')); $files_array = array(); if ($dir = @[member=dir](DIR_FS_CATALOG)) { while ($file = $dir->read()) { if (!is_dir(DIR_FS_CATALOG . $file)) { if (substr($file, strrpos($file, '.')) == $file_extension) { $files_array[] = $file; } } } sort($files_array); $dir->close(); } $values_array = explode(';', $values); $output = ''; foreach ($files_array as $file) { $output .= tep_draw_checkbox_field('nb_store_search_file[]', $file, in_array($file, $values_array)) . ' ' . tep_output_string($file) . '<br />'; } if (!empty($output)) { $output = '<br />' . substr($output, 0, -6); } $output .= tep_draw_hidden_field('configuration[' . $key . ']', '', 'id="htrn_files"'); $output .= '<script> function htrn_update_cfg_value() { var htrn_selected_files = \'\'; if ($(\'input[name="nb_store_search_file[]"]\').length > 0) { $(\'input[name="nb_store_search_file[]"]:checked\').each(function() { htrn_selected_files += $(this).attr(\'value\') + \';\'; }); if (htrn_selected_files.length > 0) { htrn_selected_files = htrn_selected_files.substring(0, htrn_selected_files.length - 1); } } $(\'#htrn_files\').val(htrn_selected_files); } $(function() { htrn_update_cfg_value(); if ($(\'input[name="nb_store_search_file[]"]\').length > 0) { $(\'input[name="nb_store_search_file[]"]\').change(function() { htrn_update_cfg_value(); }); } }); </script>'; return $output; } ?> Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
milerwan Posted May 28, 2016 Share Posted May 28, 2016 I have seen that if I choose a different CONTENT_PLACEMENT between blocks (navbar_modules_home, navbar_modules_left, navbar_modules_right), the search bar will be in a different row that the other blocks:- search bar with "home" or "left" option => first upper row position- account, checkout_basket with "right" option => second lower row positionIf I choose same option for all, they will be in the same row but as I want logo and search bar above ("home" option), I need to operate differently.Maybe the issue (and solution) is located in the script of "navbar.php" template ? <nav class="navbar<?php echo $navbar_style . $navbar_corners . $navbar_margin . $navbar_fixed; ?> navbar-custom" role="navigation"> <div class="<?php echo BOOTSTRAP_CONTAINER; ?>"> <?php if ($oscTemplate->hasBlocks('navbar_modules_home')) { echo '<div class="navbar-header">' . PHP_EOL; echo $oscTemplate->getBlocks('navbar_modules_home'); echo '</div>' . PHP_EOL; } ?> <div class="collapse navbar-collapse" id="bs-navbar-collapse-core-nav"> <?php if ($oscTemplate->hasBlocks('navbar_modules_left')) { echo '<ul class="nav navbar-nav">' . PHP_EOL; echo $oscTemplate->getBlocks('navbar_modules_left'); echo '</ul>' . PHP_EOL; } if ($oscTemplate->hasBlocks('navbar_modules_right')) { echo '<ul class="nav navbar-nav navbar-right">' . PHP_EOL; echo $oscTemplate->getBlocks('navbar_modules_right'); echo '</ul>' . PHP_EOL; } ?> </div> </div> </nav> <?php echo $navbar_css; ?> Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
milerwan Posted May 28, 2016 Share Posted May 28, 2016 (edited) It's ok I have found. :)If you want all block in a same row change "navbar.php" template like that : <nav class="navbar<?php echo $navbar_style . $navbar_corners . $navbar_margin . $navbar_fixed; ?> navbar-custom" role="navigation"> <div class="<?php echo BOOTSTRAP_CONTAINER; ?>"> <?php if ($oscTemplate->hasBlocks('navbar_modules_home')) { echo '<div class="navbar-header">' . PHP_EOL; echo $oscTemplate->getBlocks('navbar_modules_home'); } ?> <div class="collapse navbar-collapse" id="bs-navbar-collapse-core-nav"> <?php if ($oscTemplate->hasBlocks('navbar_modules_left')) { echo '<ul class="nav navbar-nav">' . PHP_EOL; echo $oscTemplate->getBlocks('navbar_modules_left'); echo '</ul>' . PHP_EOL; } if ($oscTemplate->hasBlocks('navbar_modules_right')) { echo '<ul class="nav navbar-nav navbar-right">' . PHP_EOL; echo $oscTemplate->getBlocks('navbar_modules_right'); echo '</ul>' . PHP_EOL; } echo '</div>' . PHP_EOL; ?> </div> </div> </nav> <?php echo $navbar_css; ?> Edited May 28, 2016 by milerwan Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
Mikepo Posted June 6, 2016 Share Posted June 6, 2016 @@milerwan, I've been trying to add this search tool to the navbar, without success. I see you created a new directory under modules, called navbar_modules. Can you tell me, by giving detailed instructions, how to add this module ? I've been trying, but my knowledge is limited, thanks in advance Mike Quote osC CE live - developing osC Phoenix adding modules with no core changes(awesome and easy!) Link to comment Share on other sites More sharing options...
milerwan Posted June 7, 2016 Share Posted June 7, 2016 (edited) @@milerwan, I've been trying to add this search tool to the navbar, without success. I see you created a new directory under modules, called navbar_modules. Can you tell me, by giving detailed instructions, how to add this module ? I've been trying, but my knowledge is limited, thanks in advance Mike Here are the main files to have search bar in navbar. It works but I personally have given up using it and I kept it in the content area to keep clean navbar. includes/modules/navbar_modules/nb_store_search.php : <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2015 osCommerce Released under the GNU General Public License */ class nb_store_search { var $code = 'nb_store_search'; var $group = 'navbar_modules_home'; var $title; var $description; var $sort_order; var $enabled = false; function nb_store_search() { $this->title = MODULE_NAVBAR_STORE_SEARCH_TITLE; $this->description = MODULE_NAVBAR_STORE_SEARCH_DESCRIPTION; if ( defined('MODULE_NAVBAR_STORE_SEARCH_STATUS') ) { $this->sort_order = MODULE_NAVBAR_STORE_SEARCH_SORT_ORDER; $this->enabled = (MODULE_NAVBAR_STORE_SEARCH_STATUS == 'True'); switch (MODULE_NAVBAR_STORE_SEARCH_PLACEMENT) { case 'Home': $this->group = 'navbar_modules_home'; break; case 'Left': $this->group = 'navbar_modules_left'; break; case 'Right': $this->group = 'navbar_modules_right'; break; } } } function getOutput() { global $request_type, $oscTemplate; $search_box = tep_navbar_store_search('btn-info', (MODULE_NAVBAR_STORE_SEARCH_FUNCTIONS == 'Descriptions')); // define typeahead scripts $script = '<script src="' . tep_href_link('ext/bootstrap-plugins/typeahead/bootstrap3-typeahead.min.js', null, $request_type) . '"></script>'; $script .= '<script src="' . tep_href_link('ext/modules/content/header/store_search/content_searches.min.js', null, $request_type) . '"></script>'; $oscTemplate->addBlock($script, 'footer_scripts'); ob_start(); require(DIR_WS_MODULES . 'navbar_modules/templates/store_search.php'); $data = ob_get_clean(); $oscTemplate->addBlock($data, $this->group); } function isEnabled() { return $this->enabled; } function check() { return defined('MODULE_NAVBAR_STORE_SEARCH_STATUS'); } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Search Module', 'MODULE_NAVBAR_STORE_SEARCH_STATUS', 'True', 'Do you want to add the module to your shop?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_NAVBAR_STORE_SEARCH_PLACEMENT', 'Left', 'Should the module be loaded in the Left or Right or the Home area of the Navbar?', '6', '1', 'tep_cfg_select_option(array(\'Left\', \'Right\', \'Home\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Extended Store Search Functions', 'MODULE_NAVBAR_STORE_SEARCH_FUNCTIONS', 'Standard', 'Do you want to enable search function in descriptions?', '6', '1', 'tep_cfg_select_option(array(\'Standard\', \'Descriptions\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Pages', 'MODULE_NAVBAR_STORE_SEARCH_PAGES', '" . implode(';', $this->get_default_pages()) . "', 'The pages to add the Store Search\'s results.', '6', '0', 'nb_store_search_show_pages', 'nb_store_search_pages(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_NAVBAR_STORE_SEARCH_SORT_ORDER', '520', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_NAVBAR_STORE_SEARCH_STATUS', 'MODULE_NAVBAR_STORE_SEARCH_PLACEMENT', 'MODULE_NAVBAR_STORE_SEARCH_FUNCTIONS', 'MODULE_NAVBAR_STORE_SEARCH_PAGES', 'MODULE_NAVBAR_STORE_SEARCH_SORT_ORDER'); } function get_default_pages() { return array( 'shipping.php', 'contact_us.php', 'conditions.php', 'cookie_usage.php', 'privacy.php', 'login.php', 'address_book.php', 'create_account.php', 'account_history.php', 'advanced_search.php', 'products_new.php', 'reviews.php', 'ssl_check.php', 'specials.php', 'shopping_cart.php'); } } function tep_navbar_store_search($btnclass ='btn-default', $description = true) { global $request_type; $search_link = '<div class="searchbox-margin">'; $search_link .= tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', $request_type, false), 'get', 'class="form-horizontal"'); $search_link .= ' <div class="input-group">' . tep_draw_input_field('keywords', '', 'required placeholder="' . MODULE_NAVBAR_STORE_SEARCH_PLACEHOLDER . '" id="quick_search" data-provide="typeahead" autocomplete="off" style="margin-right:-2px;"', 'search') . ' <span class="input-group-btn"><button type="submit" class="btn ' . $btnclass .'" style="border-top-left-radius: 0px; border-bottom-left-radius: 0px;"><i class="fa fa-search"></i></button></span>'; if (tep_not_null($description) && ($description === true)) { $search_link .= tep_draw_hidden_field('search_in_description', '1'); } $search_link .= ' </div>'; $search_link .= '</div>'; $search_link .= tep_hide_session_id() . '</form>'; return $search_link; } function nb_store_search_show_pages($text) { return nl2br(implode("\n", explode(';', $text))); } function nb_store_search_pages($values, $key) { global $PHP_SELF; $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.')); $files_array = array(); if ($dir = @[member='dir'](DIR_FS_CATALOG)) { while ($file = $dir->read()) { if (!is_dir(DIR_FS_CATALOG . $file)) { if (substr($file, strrpos($file, '.')) == $file_extension) { $files_array[] = $file; } } } sort($files_array); $dir->close(); } $values_array = explode(';', $values); $output = ''; foreach ($files_array as $file) { $output .= tep_draw_checkbox_field('nb_store_search_file[]', $file, in_array($file, $values_array)) . ' ' . tep_output_string($file) . '<br />'; } if (!empty($output)) { $output = '<br />' . substr($output, 0, -6); } $output .= tep_draw_hidden_field('configuration[' . $key . ']', '', 'id="htrn_files"'); $output .= '<script> function htrn_update_cfg_value() { var htrn_selected_files = \'\'; if ($(\'input[name="nb_store_search_file[]"]\').length > 0) { $(\'input[name="nb_store_search_file[]"]:checked\').each(function() { htrn_selected_files += $(this).attr(\'value\') + \';\'; }); if (htrn_selected_files.length > 0) { htrn_selected_files = htrn_selected_files.substring(0, htrn_selected_files.length - 1); } } $(\'#htrn_files\').val(htrn_selected_files); } $(function() { htrn_update_cfg_value(); if ($(\'input[name="nb_store_search_file[]"]\').length > 0) { $(\'input[name="nb_store_search_file[]"]\').change(function() { htrn_update_cfg_value(); }); } }); </script>'; return $output; } ?> includes/modules/navbar_modules/templates/store_search.php : <div class="col-md-4 col-sm-4 col-xs-12"> <?php echo $search_box; ?> </div> includes/languages/english/modules/navbar_modules/nb_store_search.php: <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2014 osCommerce Released under the GNU General Public License */ define('MODULE_NAVBAR_STORE_SEARCH_TITLE', 'Store Search Bar'); define('MODULE_NAVBAR_STORE_SEARCH_DESCRIPTION', 'Adds your Store Search Bar into the Navbar Area of your site.'); define('MODULE_NAVBAR_STORE_SEARCH_PLACEHOLDER', 'Site search'); // for ext module define('MODULE_NAVBAR_STORE_SEARCH_MORE_PRODUCT', 'View more products...'); define('MODULE_NAVBAR_STORE_SEARCH_NOT_FOUND', 'No products found. Clic here!'); define('MODULE_NAVBAR_STORE_SEARCH_PAGE', 'Page of %s'); Edited June 7, 2016 by milerwan Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
ArtcoInc Posted August 17, 2016 Share Posted August 17, 2016 @@milerwan @@Gergely Good afternoon, First off, Gwenn, thank you *VERY* much for your adaptation of this code into a NavBar module. I too had spent a lot of time trying to adapt this as a NavBar module, without sucess. But, with your code (and a few tiny tweaks), I have been able to get this to work! :) I do have two remaining issues, though ... 1) Before installing this module, the right portion of the NavBar is a certain distance from the right side of the screen ,,, After I install this module, the entire right portion of the NavBar shifts to the left by about 15 pixels. I've spent a lot of time in FireBug trying to figure out where this shift is coming from, but with no luck (yet). Any ideas? @@Gergely 2) When the user starts to type something into the search box, the found suggestions are shown in the drop-down. But, the drop-down is the same width as the search box, and the found suggestions are often wider than the drop-down, resulting in text being written over the underlying page. Is there any way to define the width of the drop-down, so that it is wider than the search box? Thank you both for your great work! Malcolm Quote Link to comment Share on other sites More sharing options...
tgely Posted August 18, 2016 Author Share Posted August 18, 2016 @@ArtcoInc1. First of all this module was designed to previous BS version as a "div" class based module. I dont use the latest but maybe are there 3 block left center and right? Put it in the center block instead.2. I use wider search bar and put this code into user.css /* typeahead */ ul.typeahead>li>a { white-space: normal; } but this could be nothing if you use another element style html code base. Quote osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
ArtcoInc Posted August 18, 2016 Share Posted August 18, 2016 @@Gergely Thank you for your reply! I realize that I am asking about code you didn't write, so I do appreciate you taking the time to reply. 1) The current 'standard' for the NavBar has three placement choices: Home, Left, or Right. The image above is for the Right option. Either of the other options places the search box on the left side of the NavBar ... not where I was wanting to put it. I will spend some more time in FireBug to see if I can figure out where the 15px shift is coming from. If push comes to shove, I can probably counter the shift with some additional CSS. 2) I know *nothing* about JavaScript, so I am -assuming- that the drop-down is inheriting it's width from the width of the search box above it. Is there any way to override this, and code in a different width? Once again, thank you very much! Malcolm Quote Link to comment Share on other sites More sharing options...
ArtcoInc Posted August 18, 2016 Share Posted August 18, 2016 (edited) @@Gergely 2. I use wider search bar and put this code into user.css /* typeahead */ ul.typeahead>li>a { white-space: normal; } but this could be nothing if you use another element style html code base. This sort of works, in that it enables word-wrap within the drop-down. This is better than before (thank you!), but I would still like to make the drop-down wider, if possible. Thank you once again! Malcolm Edited August 18, 2016 by ArtcoInc Quote Link to comment Share on other sites More sharing options...
ArtcoInc Posted August 18, 2016 Share Posted August 18, 2016 @@Gergely 2. I use wider search bar and put this code into user.css /* typeahead */ ul.typeahead>li>a { white-space: normal; } but this could be nothing if you use another element style html code base. As an update, this worked for me ... /* typeahead */ ul.typeahead>li>a { white-space: normal; } ul.typeahead.dropdown-menu { width: 350px; } Thank you again for all of your help! Malcolm Quote Link to comment Share on other sites More sharing options...
ArtcoInc Posted August 18, 2016 Share Posted August 18, 2016 @@milerwan @@Gergely Ok, found the source of the 15px shift ... in /includes/modules/navbar_modules/templates/store_search.php, replace <div class="col-md-4 col-sm-4 col-xs-12"> <?php echo $search_box; ?> </div> with <li> <?php echo $search_box; ?> </li> Now, the entire NavBar doesn't shit, this module now follows the NavBar coding 'standard', and you can still use CSS to style and position (padding/margin) the search box within the NavBar as you wish. HTH Malcolm (on to the next challenge :thumbsup: ) frankl 1 Quote Link to comment Share on other sites More sharing options...
♥Tsimi Posted August 18, 2016 Share Posted August 18, 2016 (edited) @@ArtcoInc Malcolm, bear in mind that the smallest screen (XS) has only 320px width, I think. Which would mean that your dropdown menu will get cut off if you use 350px. Modern phones (smartphones) should be able to handle at least 360px width which would be OK. Edited August 18, 2016 by Tsimi Quote Link to comment Share on other sites More sharing options...
ArtcoInc Posted August 18, 2016 Share Posted August 18, 2016 @@Tsimi Thanks for the catch! You are absolutely correct. I was trying to get things to fit nicely on the larger screens, and I had forgotten about the smallest ones. As you said, with the width set to 350px, there was horizontal scrolling at the smallest (320px x 480px) setting. Dropping the width down to 300px filled my screen with no horizontal scrolling. There is word-wrap with the longer search results, but that's better than the alternatives B) Other people with other layouts may need to adjust this further for themselves. Malcolm Quote Link to comment Share on other sites More sharing options...
milerwan Posted August 29, 2016 Share Posted August 29, 2016 (edited) After some tests, it seems that the first result of search is not displayed.I have modified the first line to have more resultats displayed : // if ($r > 5) { if ($r > 10) { $array[] = array('icon' => "plus-circle", 'title' => MODULE_CONTENT_HEADER_STORE_SEARCH_MORE_PRODUCT, 'href' => tep_href_link('advanced_search_result.php', 'keywords=' . urlencode(str_replace(' ', ' ', $query)) . '&search_in_description=' . (MODULE_CONTENT_HEADER_STORE_SEARCH_FUNCTIONS == 'Descriptions' ? 1 : 0), $request_type), 'price' =>null); break; But the first result find with normal advanced search system is not displayed by store search system(7 items found with advanced search vs 6 items displayed with store search).Is someone has also noticed that before ? Edited August 29, 2016 by milerwan Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
milerwan Posted August 29, 2016 Share Posted August 29, 2016 Sorry here is the picture : Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
milerwan Posted August 29, 2016 Share Posted August 29, 2016 (edited) It seems that the number of displayed products can't be more than 6 items even with sentence "$r > 10 " updated... How could I perform more than 6 items displayed ? It's ok I have found the answer, just modifiy the limit of products at the end of this sentence "p.products_status limit 11");" $sqlquery = tep_db_query("SELECT distinct(p.products_id), pd.products_name, pd.products_head_title_tag_alt, p.products_price, p.products_tax_class_id FROM products_description pd, products p WHERE" . $like_statement . " AND pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_status limit 11"); Edited August 29, 2016 by milerwan Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
milerwan Posted August 30, 2016 Share Posted August 30, 2016 (edited) I have noticed this variable that seems related to nothing : //For Each Category We Found $categories_found = ''; Currently, the names of my categories have 1 generic word (that is found in several categories) and 1 unique model word just after but current research don't take into account the unique word (and the most important). When I write "pièces détachées", these words are found and repeated for each category : - Pièces détachées PSP / PS vita - Pièces détachées PS2- Pièces détachées PS3 But when I want to add the unique model word to precise my search, the search failed, so it is impossible to find a specific category ! :- "Pièces détachées PS3" -> return nothing when try to write PS3 (or hidden PS4 category) just after word "accessoires" How can we make research relevant for categories?Thanks ! Edited August 30, 2016 by milerwan Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
tgely Posted August 30, 2016 Author Share Posted August 30, 2016 @@milerwanits seems to be a case sensitive search. (s <> S) Quote osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
milerwan Posted August 30, 2016 Share Posted August 30, 2016 @@milerwan its seems to be a case sensitive search. (s <> S) Do you mean the word is not found if it is written with a capital letter or not? In my case, regardless of upper or lower case, if the word does not appear among other categories, it seems it is not included in search results... @@Gergely Have you tested from your side to see the result of this type of research? Quote Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.