Jump to content

Search bar not working properly with friendly URL


Recommended Posts

Hi,

 

Since I activated friendly URL my front office's search bar doesn't work on product pages. It works just fine in other areas (it goes to URL www.mystore.com/search.php...), the problem comes when you are in a product page and try to search for a product, then it goes to www.mystore.com/currentcategory/search.php... obviously it tells you the page doesn't exist 'cause of the category thing.

 

I'm using the jbx_menu search bar, this is the code which I beIieve I have to modify (if it's not, I'm sorry that's all I've seen search related for the moment)

 

    <script type="text/javascript" src="{$menu.path}js/search.js"></script>
 {elseif $smarty.const._PS_VERSION_|substr:0:3 eq '1.4'}
 <script type="text/javascript">
 //<!--
 {literal}
 $('document').ready( function() {
  $("#search_query_menu")
   .autocomplete(
 '{/literal}{if $menu.search_ssl == 1}{$link->getPageLink('search.php', true)}{else}{$link->getPageLink('search.php')}{/if}{literal}', {
  minChars: 3,
  max: 10,
  width: 500,
  selectFirst: false,
  scroll: false,
  dataType: "json",
  formatItem: function(data, i, max, value, term) {
   return value;
  },
  parse: function(data) {
   var mytab = new Array();
   for (var i = 0; i < data.length; i++)
    mytab[mytab.length] = { data: data[i], value: data[i].cname + ' > ' + data[i].pname };
   return mytab;
  },
  extraParams: {
   ajaxSearch: 1,
   id_lang: 2
  }
 }
   )
   .result(function(event, data, formatted) {
 $('#search_query_menu').val(data.pname);
 document.location.href = data.product_link;
   })
 });
 {/literal}
 //-->
 </script>

 

How can I fix it?

Link to comment
Share on other sites

  • 2 weeks later...
×
×
  • Create New...