Products Search with ajax autocomplete question

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Mich-adg
Forum Members
Forum Members
Posts: 197
Joined: Sat Aug 02, 2008 9:08 pm

Products Search with ajax autocomplete question

Post by Mich-adg »

Hi, i try to make a search template with ajax for products.

Question 1: With the name field it works (sample from the doc of the module), but how to reach the description/details field of a product?

Question 2: this code check for the first letters of the first word from a product name, how to check for others words in a name? I know it's a jquery question but if anybody has a tip... ! Thanks !

My code:

Code: Select all

  var ajax_url = '{/literal}{module_action_link module=Products action=ajax_propval urlonly=1 jsfriendly=1}{literal}';
  ajax_url = ajax_url + '&showtemplate=false';
  $('#productname').autocomplete({
    source: function(req,add){
      var tmp =  ajax_url+'&cntnt01field=::name::&cntnt01fieldval='+req.term;
      $.getJSON(tmp,function(json){
        if( json.status == 'OK' && json.data.length > 0) {
          add(json.data);
        }
      })
    }
  });
  $('#productdesc').autocomplete({
    source: function(req,add){
      var tmp =  ajax_url+'&cntnt01field=::[b]description(dont' work...)[/b]::&cntnt01fieldval='+req.term;
      $.getJSON(tmp,function(json){
        if( json.status == 'OK' && json.data.length > 0) {
          add(json.data);
        }
      })
    }
  });
User avatar
Rolf
Dev Team Member
Dev Team Member
Posts: 7768
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Products Search with ajax autocomplete question

Post by Rolf »

Image
- + - + - + - + - + -
Latest CMSMS tutorial: FormBuilder WatchGuard
- + - + - + - + - + -
Did my post help you solving a problem at your (customers) website and it saved you many hours of work?
Great!! Buy me a cup of coffee in return as a small token of appreciation!
Mich-adg
Forum Members
Forum Members
Posts: 197
Joined: Sat Aug 02, 2008 9:08 pm

Re: Products Search with ajax autocomplete question

Post by Mich-adg »

Thanks for the sample, i will use it for global search!

But i'm just wondering how i can reach the description (or details?) field of a product.
The original search field of tpl of Products is:
<input id="productdesc" type="text" name="{$actionid}cd_proddesc" size="40" maxlength="255"/>
So i tried instead of ::name:: in my ajax script:
- ::desc::
- ::proddesc::
- ::details::

But nothings works for the moment.
Post Reply

Return to “Modules/Add-Ons”